Network Working Group D. Crockford Request for Comments: 4627 JSON.org Category: Informational July 2006The application/json Media Type for JavaScript Object Notation (JSON)
1. Introduction
JavaScript Object Notation (JSON) is a text format for the serialization of structured data. It is derived from the object literals of JavaScript, as defined in the ECMAScript Programming Language Standard, Third Edition [ECMA].
Crockford Informational [Page 1]
RFC 4627 JSON July 2006 1.1. Conventions Used in This DocumentThe key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].
2. JSON Grammar
A JSON text is a sequence of tokens. The set of tokens includes six structural characters, strings, numbers, and three literal names.
2.1. Values
A JSON value MUST be an object, array, number, or string, or one of the following three literal names:
Crockford Informational [Page 2]
RFC 4627 JSON July 2006
The literal names MUST be lowercase. No other literal names are allowed.
2.2. Objects
An object structure is represented as a pair of curly brackets surrounding zero or more name/value pairs (or members). A name is a string. A single colon comes after each name, separating the name from the value. A single comma separates a value from a following name. The names within an object SHOULD be unique.
2.3. Arrays
An array structure is represented as square brackets surrounding zero or more values (or elements). Elements are separated by commas.
2.4. Numbers
The representation of numbers is similar to that used in most programming languages. A number contains an integer component that may be prefixed with an optional minus sign, which may be followed by a fraction part and/or an exponent part.
Crockford Informational [Page 3]
RFC 4627 JSON July 2006
decimal-point = %x2E ; .
2.5. Strings
The representation of strings is similar to conventions used in the C family of programming languages. A string begins and ends with quotation marks. All Unicode characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F).
Crockford Informational [Page 4]
RFC 4627 JSON July 2006
char = unescaped /
escape (
%x22 / ; " quotation mark U+0022
%x5C / ; \ reverse solidus U+005C
%x2F / ; / solidus U+002F
%x62 / ; b backspace U+0008
%x66 / ; f form feed U+000C
%x6E / ; n line feed U+000A
%x72 / ; r carriage return U+000D
%x74 / ; t tab U+0009
%x75 4HEXDIG ) ; uXXXX U+XXXX
escape = %x5C ; \
3. Encoding
JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
4. Parsers
A JSON parser transforms a JSON text into another representation. A JSON parser MUST accept all texts that conform to the JSON grammar. A JSON parser MAY accept non-JSON forms or extensions.
Crockford Informational [Page 5]
RFC 4627 JSON July 2006 5. GeneratorsA JSON generator produces JSON text. The resulting text MUST strictly conform to the JSON grammar.
6. IANA Considerations
The MIME media type for JSON text is application/json.
Crockford Informational [Page 6]
RFC 4627 JSON July 2006
JSON has been used to exchange data between applications written in all of these programming languages: ActionScript, C, C#, ColdFusion, Common Lisp, E, Erlang, Java, JavaScript, Lua, Objective CAML, Perl, PHP, Python, Rebol, Ruby, and Scheme.
7. Security Considerations
See Security Considerations in Section 6.
8. Examples
This is a JSON object:
Crockford Informational [Page 7]
RFC 4627 JSON July 2006
}9. References 9.1. Normative References[ECMA] European Computer Manufacturers Association, "ECMAScript
Crockford Informational [Page 8]
RFC 4627 JSON July 2006
[UNICODE] The Unicode Consortium, "The Unicode Standard Version 4.0",
Crockford Informational [Page 9]
RFC 4627 JSON July 2006
Full Copyright Statement