How is JSON different then a JavaScript (programming language) object?
17th January 2012
My answer to How is JSON different then a JavaScript (programming language) object? on Quora
JSON is a carefully selected subset of JavaScript. A JSON object can only consist of dictionaries, strings, numbers (in JavaScript floating point and integers are treated as the same thing), lists, booleans and null. The spec on JSON.org is a good guide: http://json.org/
In terms of formatting, JSON objects must have double quotes around strings (JavaScript allows single quotes) and must have double quotes around dictionary keys (optional in JavaScript for keys that only contain a-zA-Z0-9_).
JSON is also strict about not leaving trailing commas on dictionary and list declarations, whereas most JavaScript engines will let you get away with those.
More recent articles
- My AI/LLM predictions for the next 1, 3 and 6 years, for Oxide and Friends - 10th January 2025
- Weeknotes: Starting 2025 a little slow - 4th January 2025
- I still don't think companies serve you ads based on spying through your microphone - 2nd January 2025