From cf665311f443fd40d7778d99acdcbcfb08a3e002 Mon Sep 17 00:00:00 2001 From: Danny Sung Date: Sun, 16 Aug 2020 03:35:22 -0700 Subject: [PATCH] fix: sessions can now save non-collection codable values (e.g. strings) --- Sources/KituraSession/SessionState.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/KituraSession/SessionState.swift b/Sources/KituraSession/SessionState.swift index 79a5cac..914d993 100644 --- a/Sources/KituraSession/SessionState.swift +++ b/Sources/KituraSession/SessionState.swift @@ -146,11 +146,15 @@ public class SessionState { return } json = array as Any - } else { + } else if mirror.displayStyle == .dictionary { guard let dict = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else { return } json = dict as Any + } else if let object = try? JSONSerialization.jsonObject(with: data) { + json = object + } else { + json = value as Any } } else { json = value