idnits 2.17.1 draft-crockford-jsonorg-json-04.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** It looks like you're using RFC 3978 boilerplate. You should update this to the boilerplate described in the IETF Trust License Policy document (see https://trustee.ietf.org/license-info), which is required now. -- Found old boilerplate from RFC 3978, Section 5.1 on line 18. -- Found old boilerplate from RFC 3978, Section 5.5 on line 457. -- Found old boilerplate from RFC 3979, Section 5, paragraph 1 on line 434. -- Found old boilerplate from RFC 3979, Section 5, paragraph 2 on line 441. -- Found old boilerplate from RFC 3979, Section 5, paragraph 3 on line 447. ** This document has an original RFC 3978 Section 5.4 Copyright Line, instead of the newer IETF Trust Copyright according to RFC 4748. ** This document has an original RFC 3978 Section 5.5 Disclaimer, instead of the newer disclaimer which includes the IETF Trust according to RFC 4748. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- == The page length should not exceed 58 lines per page, but there was 1 longer page, the longest (page 1) being 465 lines Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- The document has an RFC 3978 Section 5.2(a) Derivative Works Limitation clause. == The copyright year in the RFC 3978 Section 5.4 Copyright Line does not match the current year -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- Couldn't find a document date in the document -- date freshness check skipped. Checking references for intended status: Informational ---------------------------------------------------------------------------- -- Looks like a reference, but probably isn't: '116' on line 365 -- Looks like a reference, but probably isn't: '943' on line 365 -- Looks like a reference, but probably isn't: '234' on line 365 -- Looks like a reference, but probably isn't: '38793' on line 365 ** Obsolete normative reference: RFC 4234 (Obsoleted by RFC 5234) Summary: 4 errors (**), 0 flaws (~~), 2 warnings (==), 11 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 1 JavaScript Object Notation (JSON) D. Crockford 2 Internet Draft JSON.org 3 draft-crockford-jsonorg-json-04.txt February, 2006 4 Intended status: Informational 5 Expires: June 10, 2006 7 JavaScript Object Notation (JSON) 9 Status of this Memo 11 This document may not be modified, and derivative works of it 12 may not be created, except to publish it as an RFC and to 13 translate it into languages other than English. 15 By submitting this Internet-Draft, each author represents that any 16 applicable patent or other IPR claims of which he or she is aware 17 have been or will be disclosed, and any of which he or she becomes 18 aware will be disclosed, in accordance with Section 6 of BCP 79. 20 Internet-Drafts are working documents of the Internet Engineering 21 Task Force (IETF), its areas, and its working groups. Note that 22 other groups may also distribute working documents as 23 Internet-Drafts. 25 Internet-Drafts are draft documents valid for a maximum of six months 26 and may be updated, replaced, or obsoleted by other documents at any 27 time. It is inappropriate to use Internet-Drafts as reference 28 material or to cite them other than as "work in progress." 30 The list of current Internet-Drafts can be accessed at 31 http://www.ietf.org/ietf/1id-abstracts.txt. 33 The list of Internet-Draft Shadow Directories can be accessed at 34 http://www.ietf.org/shadow.html. 36 This Internet Draft will expire on June 10, 2006. 38 Copyright Notice 40 Copyright (C) The Internet Society (2006). 42 Abstract 44 JavaScript Object Notation (JSON) is a light-weight, text-based, 45 language-independent, data interchange format. It was derived from 46 the ECMAScript Programming Language Standard. JSON defines a small 47 set of formatting rules for the portable representation of structured 48 data. 50 Conventions used in this document 52 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 53 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 54 document are to be interpreted as described in [RFC-2119]. 56 The grammatical rules in this document are to be interpreted as 57 described in [RFC-4234]. 59 1. Introduction 61 JavaScript Object Notation (JSON) is a text format for the 62 serialization of structured data. It is derived from the object 63 literals of JavaScript, as defined in the ECMAScript 64 Programming Language Standard, Third Edition [ECMA]. 66 JSON can represent four primitive types (strings, numbers, booleans, 67 and null) and two structured types (objects and arrays). 69 A string is a sequence of zero or more Unicode characters [UNICODE]. 71 An object is an unordered collection of zero or more name/value 72 pairs, where a name is a string, and a value is a string, number, 73 boolean, null, object, or array. 75 An array is an ordered sequence of zero or more values. 77 The terms "object" and "array" come from the conventions of 78 JavaScript. 80 JSON's design goals were to be minimal, portable, textual, and a 81 subset of JavaScript. 83 2. JSON Grammar 85 A JSON text is a sequence of tokens. The set of tokens includes six 86 structural characters, strings, numbers, and three literal names. 88 A JSON text is a serialized object or array. 90 JSON-text = object / array 92 These are the six structural characters: 94 begin-array = ws %x5B ws ; [ left square bracket 96 begin-object = ws %x7B ws ; { left curly bracket 98 end-array = ws %x5D ws ; ] right square bracket 100 end-object = ws %x7D ws ; } right curly bracket 102 name-separator = ws %x3A ws ; : colon 104 value-separator = ws %x2C ws ; , comma 106 Insignificant whitespace is allowed before or after any of the six 107 structural characters. 109 ws = *( 110 %x20 / ; Space 111 %x09 / ; Horizontal tab 112 %x0A / ; Line feed or New line 113 %x0D ; Carriage return 114 ) 116 2.1. Values 118 A JSON value MUST be a object, array, number, or string, or one of 119 the three literal names: 121 false 122 null 123 true 125 The literal names MUST be in lower case. No other literal names 126 are allowed. 128 value = false / null / true / object / array / number / string 130 false = %x66.61.6c.73.65 ; false 132 null = %x6e.75.6c.6c ; null 134 true = %x74.72.75.65 ; true 136 2.2. Objects 138 An object structure is represented as a pair of curly brackets 139 surrounding zero or more name/value pairs (or members). A name is 140 a string. A single colon comes after each name, separating the 141 name from the value. A single comma separates a value from a 142 following name. The names within an object SHOULD be unique. 144 object = begin-object [ member *( value-separator member ) ] 145 end-object 147 member = string name-separator value 149 2.3. Arrays 151 An array structure is represented as square brackets surrounding 152 zero or more values (or elements). Elements are separated by 153 commas. 155 array = begin-array [ value *( value-separator value ) ] 156 end-array 158 2.4. Numbers 160 The representation of numbers is similar to that used in most 161 programming languages. A number contains an integer component 162 which may be prefixed with an optional minus sign, which may be 163 followed by a fraction part and/or an exponent part. 165 Octal and hex forms are not allowed. Leading zeros are not 166 allowed. 168 A fraction part is a decimal point followed by one or more digits. 170 An exponent part begins with the letter E in upper or lower case, 171 which may be followed by a plus or minus sign. The E and optional 172 sign are followed by one or more digits. 174 Numeric values that cannot be represented as sequences of digits 175 (such as Infinity and NaN) are not permitted. 177 number = [ minus ] int [ frac ] [ exp ] 179 decimal-point = %x2E ; . 181 digit1-9 = %x31-39 ; 1-9 183 e = %x65 / %x45 ; e E 185 exp = e [ minus / plus ] 1*DIGIT 187 frac = decimal-point 1*DIGIT 189 int = zero / ( digit1-9 *DIGIT ) 191 minus = %x2D ; - 193 plus = %x2B ; + 195 zero = %x30 ; 0 197 2.5. Strings 199 The representation of strings is similar to conventions used in 200 the C family of programming languages. A string begins and ends 201 with quotation marks. All Unicode characters may be placed within 202 the quotation marks except for the characters which must be 203 escaped: quotation mark, reverse solidus, and the control 204 characters (U+0000 through U+001F). 206 Any character may be escaped. If the character is in the Basic 207 Multilingual Plane (U+0000 through U+FFFF) then it may be 208 represented as a six-character sequence: a reverse solidus 209 followed by the lower case letter u followed by four hexadecimal 210 digits which encode the character's code point. The hexadecimal 211 letters A though F can be in upper or lower case. So, for 212 example, a string containing only a single reverse solidus 213 character may be represented as "\u005C". 215 Alternatively, there are two-character sequence escape 216 representations of some popular characters. So, for example, a 217 string containing only a single reverse solidus character may be 218 represented more compactly as "\\". 220 To escape an extended character that is not in the Basic 221 Multilingual Plane, then the character is represented as a 222 twelve-character sequence, encoding the UTF-16 surrogate pair. 223 So, for example, a string containing only the G clef character 224 (U+1D11E) may be represented as "\uD834\uDD1E". 226 string = quotation-mark *char quotation-mark 228 char = unescaped / 229 escape ( 230 %x22 / ; " quotation mark U+0022 231 %x5C / ; \ reverse solidus U+005C 232 %x2F / ; / solidus U+002F 233 %x62 / ; b backspace U+0008 234 %x66 / ; f form feed U+000C 235 %x6E / ; n line feed U+000A 236 %x72 / ; r carriage return U+000D 237 %x74 / ; t tab U+0009 238 %x75 4HEXDIG ) ; uXXXX U+XXXX 240 escape = %x5C ; \ 242 quotation-mark = %x22 ; " 244 unescaped = %x20-21 / %x23-5B / %x5D-10FFFF 246 3. Encoding 248 JSON text SHALL be encoded in Unicode. The default encoding is UTF-8. 250 Since the first two characters of a JSON text will always be ASCII 251 characters [RFC-0020], it is possible to determine if an octet stream 252 is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the 253 pattern of nulls in the first four octets. 255 00 00 00 xx UTF-32BE 256 00 xx 00 xx UTF-16BE 257 xx 00 00 00 UTF-32LE 258 xx 00 xx 00 UTF-16LE 259 xx xx xx xx UTF-8 261 4. Parsers 263 A JSON parser transforms a JSON text into another representation. A 264 JSON parser MUST accept all texts that conform to the JSON grammar. 265 A JSON parser MAY accept non-JSON forms or extensions. 267 An implementation may set limits on the size of texts that it 268 accepts. An implementation may set limits on the maximum depth of 269 nesting. An implementation may set limits on the range of numbers. 270 An implementation may set limits on the length and character contents 271 of strings. 273 5. Generators 275 A JSON generator produces JSON text. The resulting text MUST 276 strictly conform to the JSON grammar. 278 6. IANA Considerations 280 The MIME media type for JSON text is application/json. 282 Type name: text 284 Subtype name: json 286 Required parameters: n/a 288 Optional parameters: n/a 290 Encoding considerations: 8bit if UTF-8; binary if UTF-16 or UTF-32 292 JSON may be represented using UTF-8, UTF-16 or UTF-32. When JSON 293 is written in UTF-8, JSON is 8bit-compatible. When JSON is written 294 in UTF-16 or UTF-32, the binary content-transfer-encoding must be 295 used. 297 Security considerations: 299 Generally there are security issues with scripting languages. 300 JSON is a subset of JavaScript, but it is a safe subset that 301 excludes assignment and invocation. 303 A JSON text can be safely passed into JavaScript's eval() 304 function (which compiles and executes a string) if all of the 305 characters not enclosed in strings are in the set of characters 306 which form JSON tokens. This can be quickly determined in 307 JavaScript with two regular expressions and calls to the test and 308 replace methods. 310 var my_JSON_object = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test( 311 text.replace(/"(\\.|[^"\\])*"/g, ''))) && 312 eval('(' + text + ')'); 314 Interoperability considerations: n/a 316 Published specification: RFC-XXXX 318 Applications that use this media type: 320 JSON has been used to exchange data between applications written 321 in all of these programming languages: ActionScript, C, C#, 322 ColdFusion, Common Lisp, E, Erlang, Java, JavaScript, Lua, 323 Objective CAML, Perl, PHP, Python, Rebol, Ruby, and Scheme. 325 Additional information: 327 Magic number(s): n/a 328 File extension(s): .json 329 Macintosh file type code(s): TEXT 331 Person & email address to contact for further information: 332 Douglas Crockford 333 douglas@crockford.com 335 Intended usage: COMMON 337 Restrictions on usage: none 339 Author: 340 Douglas Crockford 341 douglas@crockford.com 343 Change controller: 344 Douglas Crockford 345 douglas@crockford.com 347 7. Security Considerations 349 See Security considerations in Section 6. 351 8. Examples 353 This is a JSON object: 355 { 356 "Image": { 357 "Width": 800, 358 "Height": 600, 359 "Title": "View from 15th Floor", 360 "Thumbnail": { 361 "Url": "http://scd.mm-b1.yimg.com/image/481989943", 362 "Height": 125, 363 "Width": "100" 364 }, 365 "IDs": [116, 943, 234, 38793] 366 } 367 } 369 Its Image member is an object whose Thumbnail member is an object 370 and whose IDs member is an array of numbers. 372 This is a JSON array containing two objects: 374 [ 375 { 376 "precision": "zip", 377 "Latitude": 37.7668, 378 "Longitude": -122.3959, 379 "Address": "", 380 "City": "SAN FRANCISCO", 381 "State": "CA", 382 "Zip": "94107", 383 "Country": "US" 384 }, 385 { 386 "precision": "zip", 387 "Latitude": 37.371991, 388 "Longitude": -122.026020, 389 "Address": "", 390 "City": "SUNNYVALE", 391 "State": "CA", 392 "Zip": "94085", 393 "Country": "US" 394 } 395 ] 397 9. References 399 9.1 Normative References 401 [ECMA] European Computer Manufacturers Association, "ECMAScript 402 Language Specification 3rd Edition", December 1999, 403 . 406 [RFC-0020] Cerf, V., "ASCII format for Network Interchange", 407 RFC 0020, October 16, 1969. 409 [RFC-2119] Bradner, S., "Key words for use in RFCs to Indicate 410 Requirement Levels", RFC 2119, March 1997. 412 [RFC-4234] Crocker, D., "Augmented BNF for Syntax Specifications: 413 ABNF", RFC 4234, October 2005. 415 [UNICODE] The Unicode Consortium, "The Unicode Standard 416 Version 4.0", 2003, 417 . 419 Author's Address 421 Douglas Crockford 422 JSON.org 423 Contact Email: douglas@crockford.com 425 Intellectual Property Statement 427 The IETF takes no position regarding the validity or scope of any 428 Intellectual Property Rights or other rights that might be claimed to 429 pertain to the implementation or use of the technology described in 430 this document or the extent to which any license under such rights 431 might or might not be available; nor does it represent that it has 432 made any independent effort to identify any such rights. Information 433 on the procedures with respect to rights in RFC documents can be 434 found in BCP 78 and BCP 79. 436 Copies of IPR disclosures made to the IETF Secretariat and any 437 assurances of licenses to be made available, or the result of an 438 attempt made to obtain a general license or permission for the use of 439 such proprietary rights by implementers or users of this 440 specification can be obtained from the IETF on-line IPR repository at 441 http://www.ietf.org/ipr. 443 The IETF invites any interested party to bring to its attention any 444 copyrights, patents or patent applications, or other proprietary 445 rights that may cover technology that may be required to implement 446 this standard. Please address the information to the IETF at ietf- 447 ipr@ietf.org. 449 Disclaimer of Validity 451 This document and the information contained herein are provided on an 452 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS 453 OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET 454 ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, 455 INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE 456 INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED 457 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 459 Copyright Statement 461 Copyright (C) The Internet Society (2006). This document is subject 462 to the rights, licenses and restrictions contained in BCP 78, and 463 except as set forth therein, the authors retain all their rights. 465 This Internet-Draft will expire on June 10, 2006.