-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsonObjSample.js
58 lines (51 loc) · 2.21 KB
/
jsonObjSample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
//json Object domain serialization schema
//
//Represents a domain of mutually referencial objects and functions.
//May contain symbolic reference to objects from outside the domain
//Objects
{"obj": id, //
"[Prototype]": ref,
"extensible": boolean,
"props": [{propDesc}],
"special": string //optional
}
{"func": id,
"[Prototype]": ref,
"extensible": boolean,
"props": [{propDesc}],
"name": string,
"src": string
}
//property values are encodede as either primitive values or one of the following "ref" objects:
{"objRef": id}
{"extern": namestr}
{"undef": "ined"}
// propDesc: propoerty descriptors
{"data": name,
"value": ref|prim,
"enumerable": boolean,
"configurable": boolean,
"writable": boolean
}
{"accessor": name,
"get": objRef,
"set": objRef,
"enumerable": boolean,
"configurable": boolean
}
*/
var D = JSON.parse('[{"obj": 0, "[Prototype]": {"extern": "Object.prototype"}, "extensible": true, "props": [\
{"data": "a", "value": 1, "enumerable": true, "configurable": true, "writable": true},\
{"data": "b", "value": 2, "enumerable": true, "configurable": true, "writable": false},\
{"accessor": "x", "get": {"objRef": 2}, "enumerable": true, "configurable": true }]},\
{"obj":1, "[Prototype]": {"objRef": 0}, "extensible": false, "props": [\
{"data": "c", "value": 3, "enumerable": false, "configurable": false, "writable": false},\
{"data": "d", "value": 4, "enumerable": true, "configurable": false, "writable": false},\
{"data": "z", "value": {"objRef": 1}, "enumerable": true, "configurable": true, "writable": false }]},\
{"func":2, "[Prototype]": {"extern": "Function.prototype"}, "name": "foo", "src": "function() {return \'x getter\'}", "extensible": true, "props": [\
{"data": "prototype", "value": {"objRef": 3}, "enumerable": false, "configurable": true, "writable": true}]},\
{"obj": 3, "[Prototype]": {"extern": "Object.prototype"}, "extensible": true, "props": [ \
{"data": "constructor", "value": {"objRef": 2}, "enumerable": false, "configurable": true, "writable": true}]},\
{"func":4, "[Prototype]": {"extern": "Function.prototype"}, "name": "bar", "src": "function bar() {return \\\"bar\\\"}", "extensible": true, "props": []}\
]');