Skip to content

Web & Internet

JSON (JavaScript Object Notation)

The idea, in plain English

JSON (JavaScript Object Notation, said 'JAY-son') is a simple text format for sending structured data between programs. It's like a filled-out form that sends information in labeled fields, instead of one long paragraph. It represents data as key-and-value pairs, like "name": "Ada", as lists, like ["math", "code"], and as nested groups of both. This lets any two programs, in any language, agree on the shape of the data passing between them.

How it works

  1. 1A program on one end turns its data into JSON text, ready to send anywhere. This step is called 'serializing'.
  2. 2That text travels over HTTP (HyperText Transfer Protocol), gets saved to a file, or moves however it needs to.
  3. 3A program on the other end reads the JSON text and turns it back into real data it can use. This step is called 'parsing'.
  4. 4Once parsed, you read individual fields the normal way, like a value inside an object or list you already know how to use.

When you'd use it

Almost every modern API (Application Programming Interface) sends and receives JSON. It's the standard shape of data flowing between a client and a server on the web.

Common beginner mistakes

  • Don't forget that JSON keys and strings must use double quotes, not single quotes. Text that breaks this rule simply fails to parse.
  • Don't compare JSON text directly between two systems to check if 'the data is the same'. Always parse it first and compare the actual values, since formatting like spacing or key order can differ even when the meaning is identical.

Try it — edit and run

Click the code to edit · press ⌘/Ctrl+↵ to run

Editable code. Tab and Shift+Tab indent. Press Escape, then Tab, to move focus out of the editor.

Expected output — hit Run to try it
name = Ada
age = 36
active = yes
skills = math, code
city = London

Not sure this is the right topic? See the learning paths → or where this leads →