将JSON反序列化为JavaScript对象
我在使用AJAX访问的Java服务器应用程序中有一个字符串。它看起来像以下内容: var json = [{ "adjacencies": [ { "nodeTo": "graphnode2", "nodeFrom": "graphnode1", "data": { "$color": "#557EAA" } } ], "data": { "$color": "#EBB056", "$type": "triangle", "$dim": 9 }, "id": "graphnode1", "name": "graphnode1" },{ "adjacencies": [], "data": { "$color": "#EBB056", "$type": "triangle", "$dim": 9 }, "id": "graphnode2", "name": "graphnode2" }]; 当从服务器提取字符串时,是否有一种简单的方法可以将其转换为活动的JavaScript对象(或数组)?还是我必须手动拆分字符串并手动构建对象?