3 ms·
What JSON parser supports non-string object keys? I've used several for various languages, and even written a few, and never encountered one that allowed such a
by jmillikin 17y ago
What JSON parser supports non-string object keys? I've used several for various languages, and even written a few, and never encountered one that allowed such a drastic deviation from the spec. Remember that JSON is only vaguely related to JavaScript -- just because some feature is possible in JavaScript (non-string keys, Infinity, etc) doesn't mean it's valid JSON. The only valid JSON is that which matches the grammar in RFC 4627[1].
For what it's worth, the corner cases in JavaScript make non-string keys very difficult to reasonably parse. For example, if {foo:"bar"} should parse to {"foo":"bar"}, then what should {1:"bar"} or {::"bar"} parse to?
[1] http://www.ietf.org/rfc/rfc4627.txt http://www.ietf.org/rfc/rfc4627.txt
- axod 17y agoI don't care about the RFC TBH, I care about what I can use in a practical use-case to transfer data internally in an optimal way. The json parser at json.org parses non quoted keys just fine, since it uses eval(). {1:"bar"} would obviously create a property "1", and {::"bar"} would obviously not be valid.