My data is currently stored in this format, stored in a JSON file:
{
"name": {
"0": ______,
"1": ______,
"2": ______
},
"xcoord": {
"0": ______,
"1": ______,
"2": ______
},
"ycoord": {
"0": ______,
"1": ______,
"2": ______
}
}
And I need to convert it into this format, as an array of objects:
[
{
"id": 0,
"name": _____,
"xcoord": _____,
"ycoord": _____
},
{
"id": 1,
"name": _____,
"xcoord": _____,
"ycoord": _____
},
{
"id": 2,
"name": _____,
"xcoord": _____,
"ycoord": _____
}
]
As you can see, I also need to take the number keys in my first data format and make them the "id" values in my second data format. (Since the position of the object in the array and the id number match up, maybe that would be another way to create the "id" key?) I would then store my second data format into a local variable to use in my JS code.
Any ideas on how I can do this? I'm not very good with restructuring this kind of data.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…