【问题标题】:Parse Json in Zoho Creator在 Zoho Creator 中解析 Json
【发布时间】:2015-05-12 14:22:21
【问题描述】:

我有一个巨大的 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 返回。 请帮助我做到这一点。

【问题讨论】:

    标签: json getjson zoho


    【解决方案1】:

    您在 Zoho Creator 中有 2 种方法用于解析 json

    • getJSON()

    • toJSONList()

    这两个函数都假定字符串作为参数,但与 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
                      .....
                      //
                }
          }
    }
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-15
      • 2020-08-14
      • 2020-01-09
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多