我有一个名为 "marks" 的地图,其具有其他地图作为字段。 我需要类似于使用forEach循环(或map)的方式来获取每个嵌套地图的键和值。
这是我的数据:
"marks" : {
"mark_01": {x: 10, y: 200},
"mark_02": {x: 200, y: 100},
...
"mark_99": {x: 1000, y: 1039}
}
我想做的是:
// This is wrong but represents the main idea
const newMarks = marks.map(mark => {
// Get the mark key "mark_number"
// Change its value (x, y)
// Return an object with the same key and the new manipulated value
})
有任何想法吗?生成的数据必须如下所示:
"marks" : {
"mark_01" : {x: 0, y: 190},
"mark_02" : {x: 190, y: 90},
...
"mark_99" : {x: 990, y: 1029}
}