Simon Willison’s Weblog

Subscribe

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.

This is How is JSON different then a JavaScript (programming language) object? by Simon Willison, posted on 17th January 2012.

Next: Which web frameworks should I focus on to make myself the most well rounded and to be able to solve the most problems as a web application developer/architect?

Previous: Are there any disadvantages to using domain hacks for your product website?

Monthly briefing

Sponsor me for $10/month and get a curated email digest of the month's most important LLM developments.

Pay me to send you less!

Sponsor & subscribe