< draft-crockford-jsonorg-json-03.txt   draft-crockford-jsonorg-json-04.txt >
JavaScript Object Notation (JSON) D. Crockford JavaScript Object Notation (JSON) D. Crockford
Internet Draft JSON.org Internet Draft JSON.org
draft-crockford-jsonorg-json-03.txt February, 2006 draft-crockford-jsonorg-json-04.txt February, 2006
Intended status: Informational Intended status: Informational
Expires: June 10, 2006 Expires: June 10, 2006
JavaScript Object Notation (JSON) JavaScript Object Notation (JSON)
Status of this Memo Status of this Memo
This document may not be modified, and derivative works of it This document may not be modified, and derivative works of it
may not be created, except to publish it as an RFC and to may not be created, except to publish it as an RFC and to
translate it into languages other than English. translate it into languages other than English.
skipping to change at line 121 skipping to change at line 121
%x09 / ; Horizontal tab %x09 / ; Horizontal tab
%x0A / ; Line feed or New line %x0A / ; Line feed or New line
%x0D ; Carriage return %x0D ; Carriage return
) )
2.1. Values 2.1. Values
A JSON value MUST be a object, array, number, or string, or one of A JSON value MUST be a object, array, number, or string, or one of
the three literal names: the three literal names:
false null true false
null
true
The literal names MUST be in lower case. No other literal names The literal names MUST be in lower case. No other literal names
are allowed. are allowed.
value = false / null / true / object / array / number / string value = false / null / true / object / array / number / string
false = %x66.61.6c.73.65 ; false false = %x66.61.6c.73.65 ; false
null = %x6e.75.6c.6c ; null null = %x6e.75.6c.6c ; null
true = %x74.72.75.65 ; true true = %x74.72.75.65 ; true
2.2. Objects 2.2. Objects
An object structure is represented as a pair of curly brackets An object structure is represented as a pair of curly brackets
surrounding zero or more name/value pairs (or members). A name is surrounding zero or more name/value pairs (or members). A name is
a string. A single colon comes after each name, separating the a string. A single colon comes after each name, separating the
name from the value. A single comma separates a value from a name from the value. A single comma separates a value from a
following name. following name. The names within an object SHOULD be unique.
object = begin-object [ member *( value-separator member ) ] object = begin-object [ member *( value-separator member ) ]
end-object end-object
member = string name-separator value member = string name-separator value
2.3. Arrays 2.3. Arrays
An array structure is represented as square brackets surrounding An array structure is represented as square brackets surrounding
zero or more values (or elements). Elements are separated by zero or more values (or elements). Elements are separated by
skipping to change at line 246 skipping to change at line 248
%x75 4HEXDIG ) ; uXXXX U+XXXX %x75 4HEXDIG ) ; uXXXX U+XXXX
escape = %x5C ; \ escape = %x5C ; \
quotation-mark = %x22 ; " quotation-mark = %x22 ; "
unescaped = %x20-21 / %x23-5B / %x5D-10FFFF unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
3. Encoding 3. Encoding
JSON text SHOULD be encoded in Unicode. The default encoding is JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
UTF-8.
Since the first two characters of a JSON text will always be ASCII Since the first two characters of a JSON text will always be ASCII
characters [RFC-0020], it is possible to determine if an octet stream characters [RFC-0020], it is possible to determine if an octet stream
is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the
pattern of nulls in the first four octets. pattern of nulls in the first four octets.
00 00 00 xx UTF-32BE 00 00 00 xx UTF-32BE
00 xx 00 xx UTF-16BE 00 xx 00 xx UTF-16BE
xx 00 00 00 UTF-32LE xx 00 00 00 UTF-32LE
xx 00 xx 00 UTF-16LE xx 00 xx 00 UTF-16LE
skipping to change at line 279 skipping to change at line 280
An implementation may set limits on the length and character contents An implementation may set limits on the length and character contents
of strings. of strings.
5. Generators 5. Generators
A JSON generator produces JSON text. The resulting text MUST A JSON generator produces JSON text. The resulting text MUST
strictly conform to the JSON grammar. strictly conform to the JSON grammar.
6. IANA Considerations 6. IANA Considerations
The MIME media type for JSON text is text/json. The MIME media type for JSON text is application/json.
Type name: text Type name: text
Subtype name: json Subtype name: json
Required parameters: n/a Required parameters: n/a
Optional parameters: n/a Optional parameters: n/a
Encoding considerations: 8bit Encoding considerations: 8bit if UTF-8; binary if UTF-16 or UTF-32
JSON may be represented using UTF-8, UTF-16 or UTF-32. When JSON
is written in UTF-8, JSON is 8bit-compatible. When JSON is written
in UTF-16 or UTF-32, the binary content-transfer-encoding must be
used.
Security considerations: Security considerations:
Generally there are security issues with scripting languages. Generally there are security issues with scripting languages.
JSON is a subset of JavaScript, but it is a safe subset that JSON is a subset of JavaScript, but it is a safe subset that
excludes assignment and invocation. excludes assignment and invocation.
A JSON text can be safely passed into JavaScript's eval() A JSON text can be safely passed into JavaScript's eval()
function (which compiles and executes a string) if all of the function (which compiles and executes a string) if all of the
characters not enclosed in strings are in the set of characters characters not enclosed in strings are in the set of characters
 End of changes. 6 change blocks. 
7 lines changed or deleted 13 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/