NSJSONSerialization start


(David Owens II) #1

I started taking a look at the `NSJSONSerialization` work that needs to be done. I’ll send a pull-request for what I have once I get some more tests running. Anyone interested can see the first commit here: https://github.com/owensd/swift-corelibs-foundation/commit/29c840fa7089dd9370d8199591dbbeb733a0105f.

That said, I’ve already seen some issues, I logged a couple here:

  - https://bugs.swift.org/browse/SR-71
  - https://bugs.swift.org/browse/SR-72

Another problem is how NSJSONSerialization works today. When things are not right (such as an invalid top-level JSON object), exceptions are raised. Obviously, this is not good. The function is marked with `throws` so I’ve started a new `ErrorType` implementation. I’ve started one here:

    public enum NSJSONSerializationError : ErrorType {
        case InvalidTopLevelType
        case InvalidKeyTypeForObject
        case InvalidValueType
    }

I’m not sure what the process really is here and how iterative you really want our pull requests. Any info would be helpful.

Thanks,
-David