What is JSON? (Part 2)

Posted by david, Wed Dec 26 21:15:00 UTC 2007

JSON has relatively few elements which are geared toward specific data types. The data types are inferred from the markup directly.

The types exposed via JSON are:

  • Data Types -
    • Numbers (4, 2E-12)
    • Boolean values (true and false)
    • Unicode strings
    • The nothing value, null
  • Structure Types -
    • Arrays
    • Objects; these are also known as a Dictionaries, or as Maps of String names to any defined type

This differs from XML, which really has only text content. Type in XML is external to the document, often specified by some schema document (DTD, XML Schema, and RelaxNG being the most common schema formats). The indirection in XML allows with greater flexibility in how data or other content is exposed; JSON by contrast often only has one logical way for the data to be structured, which leads to the 'schema' of the JSON document being exposed.

Like XML but unlike some of the binary data encodings, JSON does not have a binary data type. If you wish to transport binary data, like XML you will probably resort to base64 encoding the data for transmission

Filed Under: | Tags:

Comments