Skip to content

Commit 5d81bc3

Browse files
committed
fix encoder with object (struct, class)
1 parent 719c809 commit 5d81bc3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Sources/Lookup/Lookup.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ public extension Lookup {
600600
/// Available when rawType is in `[.dict, .string]` (if use string, it **MUST** be jsonString)
601601
var dict: [String: Any]? {
602602
switch rawType {
603-
case .dict:
603+
case .dict, .object:
604604
return rawDict
605605
case .string:
606606
if let originString = rawValue as? String,
@@ -620,7 +620,7 @@ public extension Lookup {
620620
/// Available when rawType is in `[.dict, .string]` (if use string, it **MUST** be jsonString)
621621
var dictLookup: Lookup {
622622
switch rawType {
623-
case .dict:
623+
case .dict, .object:
624624
return Lookup(rawDict)
625625
case .string:
626626
if let originString = rawValue as? String,
@@ -761,14 +761,16 @@ public func += (lhs: inout Lookup, rhs: Lookup) {
761761
extension Lookup: Codable {
762762

763763
private var codableDictionary: [String: Lookup]? {
764-
if rawType == .dict {
764+
switch rawType {
765+
case .dict, .object:
765766
var d = [String: Lookup](minimumCapacity: rawDict.count)
766767
rawDict.forEach { pair in
767768
d[pair.key] = Lookup(pair.value)
768769
}
769770
return d
771+
default:
772+
return nil
770773
}
771-
return nil
772774
}
773775

774776
private var codableArray: [Lookup]? {

0 commit comments

Comments
 (0)