Closed stevage closed 6 years ago
Hmm I really would have expected the second one to generate a failure (the key with a space... and it is a failure of sorts, it returns as 'my-key')
Although something like this would be a success.
{ my-key\m&m+*|:3}
Errors thrown aren't very good, they need some work...
pushed changes to fix {my- key : 3} .
Did not publish (yet). Want to work on the error throws a little.
Fwiw, it also allowed {my -key: 3}
but not {my - key: 3}
(haven't retested since your change).
yes,.... it would end up allowing any identifier with a single space in it; consuming the space. The only valid character when parsing field name after a space is a colon, or a comment...
summary from https://github.com/d3x0r/JSON6/blob/master/tests/TestObjectKeys.js
{ my- key:3} // fault
{ my - key:3} // fault
{ my-key { failure:true}:3} // fault
{ { my-key:3 } } // fault
{ [ my-key:3 } } // fault
{ my-key[:3 } } // fault
{ my-key]:3 } } // fault
{ 'my - key':3} // valid
{ my-key\\m&m+*|:3} // valid
{ my-key //test
:3} // valid
{ my-key /*test * / :3} // valid
In the C version, this is invalid, because it has test for identifier/nonidentifier characters, and only allows identifiers.... I removed that test from javascript version because it was excessively slow.... that and the character table is very large... https://github.com/d3x0r/SACK/blob/master/src/netlib/html5.websocket/json/unicode_non_identifiers.h
{ my-key\\m&m+*|:3} // valid
This issue appears to be resolved. Can it be closed?
This is weird. It seems to be ok to do:
and even
The doc claims that:
You definitely can't do those in ES5.