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
- Qwen2.5-Coder-32B is an LLM that can code well that runs on my Mac - 12th November 2024
- Visualizing local election results with Datasette, Observable and MapLibre GL - 9th November 2024
- Project: VERDAD - tracking misinformation in radio broadcasts using Gemini 1.5 - 7th November 2024