Skip to content

Commit 52da8bf

Browse files
add dictionary extension to main lib
1 parent 844488a commit 52da8bf

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Sources/Apollo/JSONStandardTypeConversions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ extension Dictionary: JSONEncodable {
145145
}
146146
}
147147

148+
extension Dictionary: JSONDecodable {
149+
public init(jsonValue value: JSONValue) throws {
150+
guard let dictionary = value as? Dictionary else {
151+
throw JSONDecodingError.couldNotConvert(value: value, to: Dictionary.self)
152+
}
153+
154+
self = dictionary
155+
}
156+
}
157+
148158
extension Array: JSONEncodable {
149159
public var jsonValue: JSONValue {
150160
return map() { element -> (JSONValue) in

Tests/ApolloTests/JSONTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,3 @@ class JSONTests: XCTestCase {
7474
""")
7575
}
7676
}
77-
78-
extension Dictionary: JSONDecodable {
79-
public init(jsonValue value: JSONValue) throws {
80-
guard let dictionary = value as? Dictionary else {
81-
throw JSONDecodingError.couldNotConvert(value: value, to: Dictionary.self)
82-
}
83-
84-
self = dictionary
85-
}
86-
}

0 commit comments

Comments
 (0)