【问题标题】:How can i get the value ObjectName from a json?如何从 json 中获取值 ObjectName?
【发布时间】:2014-04-10 14:30:35
【问题描述】:

我正在尝试从下面的 json 文件中获取值“ObjectName”。

我尝试过这样做: 如果我 wright objects[s],我会得到 [object Object],[object Object],[object Object]

var objects = JSON.parse(this.responseText);

for (s in objects) {
    data.push(Titanium.UI.createTableViewRow({title: "ObjectName: "
    + objects[s]
}));

This is my json file:

{
    "new": [],
    "system": [
    {
        "S": "30",
        "T": "20121107130000",
        "L": "213",
        "ObjectName": "14. Rummet"
    },
    {
        "S": "24",
        "T": "20110831163900",
        "L": "202",
        "ObjectName": null
    }
],
    "returnes": []
}

【问题讨论】:

    标签: json titanium titanium-mobile


    【解决方案1】:

    你的答案是,如果你想得到keypair value system的值,你需要像这样使用它

    var objects = this.responseText;
    
    objects.system[0].S Answer ----> 30 ;
    
    objects.system[1].S Answer ----> 24 ;
    
    objects.system[0].T Answer ----> 20121107130000;
    
    objects.system[0].L Answer ----> 213;
    
    objects.system[0].ObjectName Answer ----> 14. Rummet
    
    objects.system.length Answer ----> 2
    

    【讨论】:

      猜你喜欢
      • 2017-03-24
      • 2019-09-25
      • 2015-03-29
      • 2021-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-17
      相关资源
      最近更新 更多