Skip to content

Commit

Permalink
Update JSONSerializableExtension.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
pkh0225 committed Nov 26, 2024
1 parent 25daa28 commit 2da99fd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/SwiftHelper/Json/JSONSerializableExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]()
}

}

0 comments on commit 2da99fd

Please sign in to comment.