【发布时间】:2020-03-14 12:35:54
【问题描述】:
我的 JSON 数据如下所示:{
"objects": [
{
"name": "case1",
"description": "description of case1",
"shapes": [
{
"shape_name": "circle"
}
],
"order_ref": [
{
"id": "2233"
}
]
},
{
"name": "case2",
"description": "description of case2",
"shapes": [
{
"shape_name": "heart"
},
{
"shape_name": "square"
}
],
"order_ref": [
{
"id": "1212"
}
]
}
]
}
我需要根据数据创建一个表。 该表应如下所示:
Id Shape Name Description
2233 Circle Case1 Desc of case1
1212 Heart Case2 Desc of case2
1212 Square Case2 Desc of case2
我尝试使用地图解析 JSON 数据:我能够获取名称和描述,但无法进入形状和 order_ref。你能建议我使用地图或 forEach 的解决方案吗
【问题讨论】:
-
基本上你只需要做同样的事情,但下一级..也许发布你为获取名称和描述所做的代码
-
到目前为止你做了什么?您在哪里需要帮助?
标签: javascript json foreach javascript-objects