Layout of JSON

JSON—JSON is the JavaScript Object Notation. JSON is a lightweight data interchange format.

JSON’s usefulness is in the area of data interchange, and in some ways it is similar to XML. However, there are some key conceptual differences. Whereas XML is conceptually similar to working with databases and is designed to primarily work with sets of data, JSON is conceptually similar to arrays and collections in procedural programming languages. That means JSON is designed to be easily usable from within a procedural programming language.

JSON is built on the following data structures:


  • Name/value pairs : This may be called an object, record, structure (struct), HashTable, keyed list, or associated array.
  • List of values : This list of values is referred to an array in most programming languages./li>

Take a look at the specific layout of JSON in the following table.
  • object -> {} or { members }

  • members -> string : value or members , string : value

  • array -> [] or [ elements ]

  • elements -> value or elements , value

  • value -> string, number, object, array, boolean, null


    The Data types mainly used in JSON are:


  • String -> " " or " chars " (Any UNICODE character except " or \ or control character)

  • Chars -> char or chars

  • Char -> \"(quotation mark), \\ (reverse solidus), \/ (solidus), \b (backspace), \f (formfeed), \n (newline), \r (carriage return), \t (horizontal tab), \u (4 hexadecimal digits)

  • number -> int, int frac, int exp, int frac exp

  • int -> digit, digit 1-9 digits, - digit, - digit1-9 digits

  • frac -> . digits

  • exp -> e digitsfrac

  • digits -> digit, digit digits

  • e -> e, e+, e-, E, E+, E-



With JSON, these items take on the following forms:
  • An object is a set of name/value pairs.
    An object begins with a left brace ({) and ends with a right brace (}).
    Names are followed by a colon (:). Name/value pairs are separated by a comma (,).
  • An array is a collection of values.
    Arrays start with a left bracket ([) and end with a right
    bracket (]).
    Values within an array are separated by a comma (,).
  • A value may be one of several datatypes.
    If it is a string, it will be contained within double quotation marks.
    Other datatypes supported within an array are numbers, booleans, null, objects, and arrays.
  • A string is a collection of Unicode characters wrapped within double quotation marks.
    Characters may be escaped by using the forward slash character (/).

What is JSON?

JSON (JavaScript Object Notation) is billed as a “lightweight data-interchange format”. It is a subset of Javascript, using its ”’object literal notation”’ and as such, can simply be evaled using JavaScript’s built-in eval() method, and parsed with little effort in most other languages. As a data-interchange format, it has become increasingly popular as an alternative to XML. Its advocates generally cite its humanreadability and the ease of parsing as the main advantages. However, the key feature, I believe, is that JSON data structures translate transparently into the native data structures universal to almost all programming languages used today.