What is JSON?

Coccagerman
2 min readJun 5, 2021

JSON (JavaScript Object Notation) is a lightweight data-interchange format based on standard test and used to represent structured data using the syntax of javascript objects. It’s easy for humans to read and write and easy for machines to parse and generate. It’s commonly used to send and receive information between different web applications (for example when sending or receiving data from/to a server).

JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures.

A JSON object is an unordered set of name/value pairs. The object begins with {left brace and ends with }right brace. Each name is followed by :colon and the name/value pairs are separated by ,comma.

An example of JSON structure.

Methods

Javascript has built in methods that make it easy to parse code from/into JSON.

- JSON.parse() analyzes the JSON string and transforms it into javascript

- JSON.stringify() analyzes the javascript code and translates it into JSON.

Other notes

  • JSON it’s just a data format — It contains only properties, not methods.
  • JSON requires the use of double quotes (“ ”) for strings and property names. Single quotes are not valid (‘ ’).
  • A coma or a point in the wrong place can make the JSON file not to work. There’re many apps that validate and generate JSON for you like JSONLint.

--

--