swift-json-gen icon indicating copy to clipboard operation
swift-json-gen copied to clipboard

Handle unparsable dictionaries better

Open mac-cain13 opened this issue 8 years ago • 0 comments

Only [String: *] dicts are supported by JsonGen, since a Json dictionary key always is a string. I tried to outsmart JsonGen by creating this:

enum MyKey: String {
  case SomeKey = "SomeKey"
}

struct MyJsonStruct {
  let someDict: [MyKey: OtherJsonStruct]
}

JsonGen gave me the impression that it could work because the Dictionary.decodeJson method takes a key decoder that is somewhat generic. But it really only will work with String keys because of the direct case to [Key: Value] that JsonGen performs, maybe this is something that could be a little stricter.

mac-cain13 avatar Feb 22 '16 08:02 mac-cain13