我有一个巨大的JSON,我需要在zoho创建者中解析它,然后将这些数据上传到zoho报告中。
JSON数据:
{
"response": {
"result": {
"SalesOrders": {
"row": [
{
"no": "1",
"FL": [
{
"content": "15 Taco Bar - Fabio 5/12",
"val": "Subject"
},
{
"content": "Emily Fabio",
"val": "Contact Name"
},
{
"content": "Confirmed for Delivery",
"val": "Status"
},
{
"content": "Chaska Private Parties",
"val": "Account Name"
}
]
}
]
}
},
"uri": "/crm/private/json/SalesOrders/getRecords"
}
}
jsonstring=jsondata.toString(); //convert json data to string
resp1=remove(jsonstring,"{\"response\":{\"result\":{\"Potentials\":{\"row\":");//Formatted json
list={"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "15"}; --This is list
jsonmap = map();
jsonmap=jsonstring.toMap(); //Convert json string to map
jsonlist=jsonstring.toJSONList();
address=jsonmap.get("Origin Address");
info address;
for each index j in list
{
address = jsonstring.getJSON("Origin Address"); // get data from json.
info address; // print address
}它总是显示null返回。请帮我做这个。
发布于 2015-05-13 11:07:12
在中有两个解析json的方法
这两个函数都假定字符串为参数,但与Javascript不同,您只能在getJSON中指定一个(下一个)节点。下面是解析销售订单的示例:
response = jsondata.getJSON("response");
result = response .getJSON(" result");
SalesOrders = result.getJSON("SalesOrders");
rows = SalesOrders.getJSON("row").toJSONList();
sales_order = Map();
// iterate Sales Orders
for each row in rows
{
FL = row.getJSON("FL").toJSONList() ;
// iterate parameters
for each f in FL
{
if (f.getJSON("val") != "products" )
{
// put JSON Object in Map
sales_order.put(f.getJSON("val"),f.getJSON("content") );
}
else
{
// products is JSON Array
items = f.getJSON("content").toJSONList();
// iterate product
.....
//
}
}
}希望它能帮上忙
https://stackoverflow.com/questions/30193726
复制相似问题