diff --git a/Sources/SwiftHelper/Json/JSONSerializableExtension.swift b/Sources/SwiftHelper/Json/JSONSerializableExtension.swift index 2504d58..c11765b 100644 --- a/Sources/SwiftHelper/Json/JSONSerializableExtension.swift +++ b/Sources/SwiftHelper/Json/JSONSerializableExtension.swift @@ -133,3 +133,14 @@ extension JSONSerializable { } } } + +extension Optional: JSONSerializable { + public var JSONRepresentation: [String: Any] { + guard let x = self else { return [String: Any]() } + if let value: JSONSerializable = x as? JSONSerializable { + return value.JSONRepresentation + } + return [String: Any]() + } + +}