This repository has been archived by the owner. It is now read-only.

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

Closed
nst opened this Issue Aug 29, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@nst

nst commented Aug 29, 2016

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

This comment has been minimized.

Show comment
Hide comment
@jgallagher

jgallagher Aug 30, 2016

Contributor

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.

Contributor

jgallagher commented Aug 30, 2016

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.

jgallagher added a commit that referenced this issue Aug 30, 2016

Allow leading zero with exponents; e.g., "0e1".
Fixes one of the two issues brought up in #198.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.