Last active
September 17, 2018 21:33
-
-
Save jonbrooks/a2f0f19d8bcb00b51cf1b0567d06c720 to your computer and use it in GitHub Desktop.
InfiniteRecursion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Foo { | |
let json: [Any] | |
} | |
extension Foo: Decodable { | |
enum Keys: String, CodingKey { | |
case json | |
} | |
init(from decoder: Decoder) throws { | |
let cont = try decoder.container(keyedBy: Keys.self) | |
json = try cont.decode(Array<Any>.self, forKey: .json) | |
} | |
} | |
let json = """ | |
{ | |
"json": [[ "a", "b", "C" ]] | |
} | |
""".data(using: .utf8)! | |
let obj = try? JSONDecoder().decode(Foo.self, from: json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment