简体   繁体   English

具有Javascript映射的Json结构

[英]Json structure with Javascript Mapping

Is any tool or online editor available so that it specify how to access a json element.For example if i provide json as input ,then we should get an output which will specify each item how can we access through javascript 是否有任何工具或在线编辑器可用,以便它指定如何访问json元素。例如,如果我提供json作为输入,那么我们应该得到一个输出,该输出将指定每个项目如何通过javascript访问

Example

Assume Input is 假设输入为

    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 } ] } ] } };

Output should be a structure,which will specify like 输出应该是一个结构,它将指定像

 myList.vehicleList.Vehicle[3].Severe;    

It seems like you looking backward means providing the value you need what will be the expression to get the value. 看起来您向后看意味着提供所需的值,您将需要表达该内容的表达式。 I don't have a solution for that. 我没有解决方案。

But I would like to suggest json is very easy to read, may be you are having trouble due to long chunk of string. 但是我想建议json非常易于阅读,可能是由于字符串大而麻烦。 Try this website(editor) http://jsonlint.com/ this will validate your json and give you in more readable form. 试试这个网站(编辑) http://jsonlint.com/,这将验证您的json并为您提供更具可读性的形式。 Hope this will help you in one or other way. 希望这会以一种或其他方式对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM