Vaultools
Menu

JSON (JavaScript Object Notation)

JSON is a lightweight, language-independent text format for structured data made of objects, arrays, strings, numbers, booleans and null. It is specified by RFC 8259 and ECMA-404 and is the default data format of web APIs.

The whole format on one screen

{
  "name": "Ada Lovelace",
  "age": 36,
  "admin": false,
  "tags": ["math", "poetry"],
  "address": null
}

A JSON value is one of: an object ({...} with string keys), an array ([...]), a string, a number, true, false or null. That is all of it.

What JSON does not allow

Most “invalid JSON” errors come from writing JavaScript instead:

Error messages differ between engines, but a complaint about an unexpected token near the end usually means a trailing comma, and an “unexpected end” message usually means the text was cut off.

Numbers and precision

JSON has one number type and puts no limit on size, but most parsers, including JavaScript’s, read numbers as 64-bit floating point. Integers above 9,007,199,254,740,991 (2⁵³ − 1) silently lose precision. IDs that large, such as some 64-bit database keys, should be sent as strings.

Encoding and duplicates

Common pitfalls

References

Ads on this page

Non-personalized ads help keep Vaultools free — Google decides where they appear on the page.

Go Pro to remove them →