我有一个看起来像这样的 Json 数组:
Test = [
{
"adj" : [
{
"nodeTo" : "x",
"nodeFrom" : "y",
"data":
{
"$type" : "line",
"$color" : "#A989BC",
"$value" : "number"
}
}
],
"id" : "id1",
"name" : "name1"
},
{
"adj" : [ ..... ] // I have many element in the Test array
而且我需要通过测试中的所有元素。我已经这样做了:
list = [];
for (i = 0; i < Test.lenght; i++) {
if (x == Test[i]["name"])
list.push(x + "->" + Test[i]["adj"][0]["nodeTo"] + ":" + Test[i]["adj"][0]["data"]["$value"]);
}
但它不起作用。提前致谢 :)