0
|
1 JSON in JavaScript
|
|
2
|
|
3
|
|
4 Douglas Crockford
|
|
5 douglas@crockford.com
|
|
6
|
|
7 2010-11-18
|
|
8
|
|
9
|
|
10 JSON is a light-weight, language independent, data interchange format.
|
|
11 See http://www.JSON.org/
|
|
12
|
|
13 The files in this collection implement JSON encoders/decoders in JavaScript.
|
|
14
|
|
15 JSON became a built-in feature of JavaScript when the ECMAScript Programming
|
|
16 Language Standard - Fifth Edition was adopted by the ECMA General Assembly
|
|
17 in December 2009. Most of the files in this collection are for applications
|
|
18 that are expected to run in obsolete web browsers. For most purposes, json2.js
|
|
19 is the best choice.
|
|
20
|
|
21
|
|
22 json2.js: This file creates a JSON property in the global object, if there
|
|
23 isn't already one, setting its value to an object containing a stringify
|
|
24 method and a parse method. The parse method uses the eval method to do the
|
|
25 parsing, guarding it with several regular expressions to defend against
|
|
26 accidental code execution hazards. On current browsers, this file does nothing,
|
|
27 prefering the built-in JSON object.
|
|
28
|
|
29 json.js: This file does everything that json2.js does. It also adds a
|
|
30 toJSONString method and a parseJSON method to Object.prototype. Use of this
|
|
31 file is not recommended.
|
|
32
|
|
33 json_parse.js: This file contains an alternative JSON parse function that
|
|
34 uses recursive descent instead of eval.
|
|
35
|
|
36 json_parse_state.js: This files contains an alternative JSON parse function that
|
|
37 uses a state machine instead of eval.
|
|
38
|
|
39 cycle.js: This file contains two functions, JSON.decycle and JSON.retrocycle,
|
|
40 which make it possible to encode cyclical structures and dags in JSON, and to
|
|
41 then recover them. JSONPath is used to represent the links.
|
|
42 http://GOESSNER.net/articles/JsonPath/
|