在解码的JSON中,我还有一个带有以下内容的子列表:
"steps": [{
"id": 54785,
"response": {
"attributes": {
"xsi:type”:”text1”},”message": {
"attributes": {
"xsi:type": "xsd:string"
},
"$value": "alterMultipleParameter"
},
"nextcase": {
"attributes": {
"xsi:type": "xsd:int"
},
"$value": 4823
},
"nextstep": {
"attributes": {
"xsi:type": "xsd:int"
},
"$value": 54786
},
“myid ":{"
attributes ":{"
xsi: type ":"
xsd: string "},"
$value”: ”1234”
},
"tickaction": {
"attributes": {
"xsi:type": "xsd:string"
},
"$value": "httpok"
},
"miscellaneous": {
"attributes": {
"xsi:type": "xsd:string"
},
"$value": "eyJjb250YWluZXJwZCI6ZmFsc2UsInJlYWRhYmxlQWN0aW9uIjoiYWwdWx0aXBsZUNvcnB1c1BhcmFtZXRlciBLb3JwdXNfSG9laGUgMTAwMC4wMCIsIm5leHRBY3Rpb24iOiJhZGRGcm9udCJ9"
}
}
},
{
"id": 54786….
}]
我知道如何访问步骤值及其ID
for(y=0; y < myArr.finishedRuns[i].steps.length; y++)
{
console.log(myArr.finishedRuns[i].steps[y].id);
console.log(myArr.finishedRuns[i].steps[y].miscellaneous);
}
但是如何从杂项中获得价值呢?目前,我对其他部分感到“未定义”。 miscellaneous.value将失败并显示错误。
答案 0 :(得分:0)
您可以使用forEach:
steps.forEach(data => {
console.log(data.response.miscellaneous);
});