0

是否有任何工具或在线编辑器可用,以便它指定如何访问 json 元素。例如,如果我提供 json 作为输入,那么我们应该得到一个输出,它将指定每个项目我们如何通过 javascript 访问

例子

假设输入是

    var myList={ "vehicleList": { "Vehicle": [ { "vehicleId": 88, "vehicleName": "veh1", "totalEvents": 10, "medium": 2, "Severe": 2, "Category": [ { "AlertId": 1001, "AlertName": "Overspeed", "Alertcount": 10 }, { "AlertId": 1002, "AlertName": "Sudden acceleration", "Alertcount": 40 } ] }, { "vehicleId": 87, "vehicleName": "veh2", "totalEvents": 11, "medium": 4, "Severe": 7, "Category": [ { "AlertId": 1003, "AlertName": "Overspeed", "Alertcount": 30}, { "AlertId": 1004, "AlertName": "Drunk", "Alertcount": 10 } ] }, { "vehicleId": 87, "vehicleName": "veh3", "totalEvents": 10, "medium": 2, "Severe": 2, "Category": [ { "AlertId": 1007, "AlertName": "Overspeed", "Alertcount": 10 }, { "AlertId": 1008, "AlertName": "Overspeed", "Alertcount": 77 } ] }, { "vehicleId": 86, "vehicleName": "veh4", "totalEvents": 11, "medium": 4, "Severe": 5, "Category": [ { "AlertId": 1009, "AlertName": "Overspeed", "Alertcount": 17 }, { "AlertId": 1010, "AlertName": "HighSpeed", "Alertcount": 10 } ] } ] } };

输出应该是一个结构,它将指定如下

 myList.vehicleList.Vehicle[3].Severe;    
4

1 回答 1

0

看起来你向后看意味着提供你需要的值什么将是表达式来获取值。我对此没有解决方案。

但我想建议 json 很容易阅读,可能是由于字符串太长而导致您遇到麻烦。试试这个网站(编辑器) http://jsonlint.com/这将验证您的 json 并以更易读的形式为您提供。希望这会以一种或其他方式帮助您。

于 2013-03-18T06:28:28.600 回答