JSON

From Just Solve the File Format Problem
Revision as of 09:48, 27 October 2016 by Johanvanderknijff (Talk | contribs)

Jump to: navigation, search
File Format
Name JSON
Ontology
Extension(s) .json
MIME Type(s) application/json

JSON (JavaScript Object Notation) is widely used by web applications, mobile apps, and other programs to communicate between different systems (such as between a client and server). While it is named after JavaScript, there are libraries for many other programming and scripting languages to let them use this format as well. The geospatial format GeoJSON is based on JSON, as is the remote-procedure-call protocol JSON-RPC and the JSON-LD linked-data format. The IBM standard of JSONx is an XML implementation of JSON. I-JSON is a restricted profile of JSON for Internet use.

Contents

Format

JSON is a very simply-defined format for representing data in text-based form using a few simple types, including two "compound types" which can be nested:

  • number: A decimal number, optionally including a decimal point or exponential notation. Leading zeroes are not allowed unless the only number before the decimal point is a single zero, or the number is equal to zero. (Other formats and programming languages may call these int, float, double, long, etc.)
  • string: A string of (Unicode) characters surrounded by double quotes ("). The only characters not allowed directly (without escaping) are double quotes, backslashes, or control characters; a backslash can be used to precede a quote or backslash used as a character within the string, as well as \b for backspace, \f for formfeed, \n for newline, \r for carriage return, \t for tab, and \u followed by 4 hexadecimal digits for encoding any Unicode character in the 0000-FFFF range. (Other formats and programming languages may call these string or array of char).
  • true, false, or nil are permitted as typeless values. (Other formats and programming languages may put these into boolean or pointer types.)
  • object: An associative array consisting of names and values, where the name and value are separated by a colon (:), the name/value pairs are separated by commas, and the whole object is surrounded by curly braces {}. The name is a (double-quoted) string, and the value can be any of the data types in JSON including another object. There is no inherent ordering to the values of an object. (Other formats and programming languages may call these associative arrays, hashes, or dictionaries.)
  • array: An ordered collection of values, which can each be any of the JSON data types, and are separated by commas and surrounded by square brackets []. (Other formats and programming languages may call these arrays or lists.)

JSONP

JSONP is a variant of JSON, "padded" with additional JavaScript code to permit the entire data set to be a valid piece of JS code able to be imported via a <script> statement for execution. Generally the extra code will be a function call encompassing the JSON data as its parameter, but sometimes it will be a variable assignment or other code. This gets around security restrictions in browser implementations of JavaScript which limit use of external data loaded from other sites (script statements can reference outside URLs), making it both very powerful and very dangerous if misused.

JSON Pointer

JSON Pointer (described in RFC 6901) is a syntax for referencing a specific value within a JSON document.

See also

Specs and schemas

Sample data

Utilities

Other links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox