JSON Basics

JSON or JavaScript Object Notation is a data representation standard shown in a key:value pair, just like a traditional JavaScript object.

Here's the key info you need to know about it:

  • All the data in the file must be surrounded by curly braces if you're representing it as an object, and in square brackets if it is an array.
  • Single quotes are not allowed
  • The key in each JSON must be unique and must be in double quotes
  • Numbers must not be enclosed in double-quotes, otherwise they will be treated as strings.
  • The null data type must not be enclosed in double-quotes.
  • Boolean values can only be true or false.
  • Each key:value pair must be terminated with a comma except for the last item
  • A particular object inside an array must be terminated by a comma, too.

See https://www.freecodecamp.org/news/what-is-a-json-file-example-javascript-code/

Posts in this Series