我有一个json这种格式的数据,我想将数据加载到一个对象数组中,而不用硬编码对象键。我想获取每个类别中的项目和标签,并且每个类别都有它的名称作为对象键。目前我通过
...myData.labels.name;或...items.name;无效的数据获取数据,因为名称会根据类别而变化。
[
[
{
"key": "mykey",
"category": "myCategoryKey",
"category_label": "myCategoryLabel",
"field": "filter",
"items": {
"name": [
"item1",
"item2"
]
},
"labels": {
"name": [
"Item1",
"Item2"
]
}
},
{
"key": "mykey2",
"category": "myCategoryKey2",
"category_label": "myCategoryLabel2",
"field": "filter",
"items": {
"name2": [
"item1",
"item2"
]
},
"labels": {
"name3": [
"Item1",
"Item2"
]
}
}
]
]