bignerdranch / Freddy

A reusable framework for parsing JSON in Swift.
MIT License
1.09k stars 120 forks source link

JSONFromString() throws an error on certain valid JSON strings. #198

Closed nst closed 6 years ago

nst commented 8 years ago

JSONFromString() throws an error on certain valid JSON strings.

Steps to reproduce

Run JSONFromString() with the following Swift strings as input:

"0e1"
"\"\u{0000}\""

Expected behavior

As these strings are valid JSON according to RFC 7159, JSONFromString() should return a member of the JSON enum.

Actual behavior

JSONFromString() throws an error.

jgallagher commented 8 years ago

The \u0000 problem is a known issue (see #63) that's a side-effect of our use of String.fromCString for performance sake. We'd like to fix it but not at the cost of making all string parsing significantly slower, which was true at the time that code was originally written. I'd like to see that addressed in our first Swift 3 release.

0e1 failing was intentional but not correct - I misread the spec. I'll work on a fix for it soon.