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 59 60 61 62 63 64 65 66 67 68
| var json = { contry:{ area:{ man:"12万", women:"10万" } } };
var obj = eval(json); alert(obj.constructor); alert(obj.contry.area.women);
var strJSON = "{name:'json name'}"; var obj = new Function("return" + strJSON)(); alert(obj.name); alert(obj.constructor);
var value1 = [ { "a01":"1", "a02":"2", "a03":"3", "a04":"4", }, { "b01":"2", "b02":"4", "b03":"5", "b04":"2", }, { "c01":"5", "c02":"1", "c03":"4", "c04":"11", } ]; var obj1 = eval(value1); alert(obj1[0].c01);
var value2 = { "list":[ { "password":"1230", "username":"coolcooldool" }, { "password":"thisis2", "username":"okokok" } ], "array":[ { "password":"1230", "username":"coolcooldool" }, { "password":"thisis2", "username":"okokok" } ] }; var obj2 = eval(value2); alert(obj2.list[0].password);
|