0

我想在 Titanium 中解析一个多维数组。

它是这样的: -

{"nodes":
    [{"node":
       {
        "title":"<a href=\"\/adf\/into-the-blue\">Into the Blue<\/a>",
        "Teaser":"Into the Blue Teaser.",
        "Knowledge":"<a href=fsdf">Americas<\/a>",
         ...
         ...

这就是我所做的。(它只得到第一行:()

// url 具有 JSON URL。

var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function() {
    var response = xhr.responseText;
    var resultObj = JSON.parse(response);
    Ti.API.log("The Response is " + response);
    Ti.API.log("THE RESULT " + resultObj);
    updateBanners(resultObj);
    updateTable(resultObj, catid, catregion, cattopic, listByDate);
};
xhr.open("GET", url);
xhr.send();

非常感谢

4

2 回答 2

0

也许您在解析中遗漏了一部分。

var resultObj = JSON.parse(response);

我的通常看起来像。

var resultObj = JSON.parse(response).NameOfMyRemoteFunctionResult;

我使用 WCF Web 服务进行调用,所以这是我得到的响应类型。

于 2013-04-11T17:22:08.823 回答
0

这就是我能够解决它的方法。

//Correct Response. Gives the total number of returned Records.
resultObj.nodes.length

 // and for a specific title of first row.

 resultObj.nodes[0].node["title"]

alert("Total Records are :- "+ responseObjArr.nodes.length + " and the 1st Title is:- " + responseObjArr.nodes[0].node["title"]);
于 2013-04-11T17:58:13.780 回答