首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Zoho Creator中解析Json

在Zoho Creator中解析Json
EN

Stack Overflow用户
提问于 2015-05-12 14:22:21
回答 1查看 2.8K关注 0票数 2

我有一个巨大的JSON,我需要在zoho创建者中解析它,然后将这些数据上传到zoho报告中。

JSON数据:

代码语言:javascript
复制
{
    "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返回。请帮我做这个。

EN

回答 1

Stack Overflow用户

发布于 2015-05-13 11:07:12

在中有两个解析json的方法

  • getJSON()
  • toJSONList()

这两个函数都假定字符串为参数,但与Javascript不同,您只能在getJSON中指定一个(下一个)节点。下面是解析销售订单的示例:

代码语言:javascript
复制
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
                  .....
                  //
            }
      }
}

希望它能帮上忙

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30193726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档