JSON

Dr. Greg Bernstein

Updated: August 6th, 2019

JSON

References

What is it?

JSON: JavaScript Object Notation

JSON is the the most popular general data exchange format used in modern web programming. Although the term AJAX stands for “Asynchronous JavaScript And XML” most modern web applications use JSON for these types of data exchanges.

Is it just JavaScript

Yes and No. Its a very restricted subset of JavaScript that is sufficiently powerful to model almost any data.

Essentially it is based on JavaScript objects literals, array literals, and primitive types.

Formally

From json.org

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.

JSON Object

From json.org

JSON Array

From json.org

JSON Value

From json.org

JSON String

From json.org

JSON Number

From json.org

JSON Libraries

Are available for almost all programming languages

Ada, C, C++, C#, Clojure, Cobol, Fortran, Go, Haskel, Java, JavaScript, Lisp, Lua, Perl, Python, Rust, …

You will sometimes find multiple libraries available for a language. Some are optimized for speed or size, or…

In JavaScript

From MDN JSON

  • JSON.parse(): Parse a string as JSON, optionally transform the produced value and its properties, and return the value.

  • JSON.stringify(): Return a JSON string corresponding to the specified value, …

Try it!