我有一个 Json 数组,其中包含以下元素:“adjacencies”、“data”、“id”、“name”。在某些元素中,“邻接”是不存在的。这是一个例子:
var JsonArray = [
{
"id" : "id1",
"name" : "name1",
"data" : {
"$type" : "circle",
"$color" : "#AEC43B"
}
}, //Without "adjacencies"
{
"id" : "id2",
"name" : "name2",
"data" : {
"$type" : "circle",
"$color" : "#AEC43B"
}
}, //Without "adjacencies"
{
"adjacencies": [
{
"nodeTo": "id1",
"nodeFrom": "id3",
"data": {
"$color": "#416D9C"
}
}
],
"id" : "id3",
"name" : "name3",
"data" : {
"$type" : "circle",
"$color" : "#AEC43B"
}
} //With "adjacencies"
];
第一个和第二个元素不包含“邻接”,但第三个元素包含。在循环中for (i = 0; i < JsonArray.length; i++)
如何访问第三个元素?.contain
例如,有没有财产?提前致谢:)