3 ms·
See my other comment about this not being an API level decision. At the template level and JS library level we're not doing any magic. Javascript allows keys o
by JoelSutherland 16y ago
See my other comment about this not being an API level decision.
At the template level and JS library level we're not doing any magic. Javascript allows keys of object literals to be written without quotes when they aren't reserved. We didn't implement a layer on top of Javascript enforcing otherwise.
There is nothing controversial about this.
- thwarted 16y agoAt the template level and JS library level we're not doing any magic. Javascript allows keys of object literals to be written without quotes Javascript does, but the JSON standard does not. Both on the root page of JSON.org and in sections 2.2 and 2.5 of RFC4627, JSON object member's keys are strings, and strings are defined as delimited by double quotes. It's pretty explicitly defined in the RFC. So while you can say that your structure is Javascript code, you can't really say it's JSON. Saying it is JSON but not following the JSON standard only leads to confusion and failures when people try to parse it with JSON parsers rather than unsafely evaluating it with a Javascript interpreter. And no one should be encouraging the use of javascript eval to unserialize JSON due to security concerns.
- JoelSutherland 16y agoThe API is JSON. It only accepts valid JSON and it returns valid JSON. Library != API