I have been searching for an answer to this specific kind of format, but was not able to find any to solve this specific issue.
The situation is, I have a kind of JSON format that I can't work with in combination with mongoDB. I wish to alter the format of the JSON data to a normal JavaScript object. Now the data is over 2,000 entries long, so I can't handle it manually. And I couldn't make the JSON.parse(data) work for this kind of special format.
Here an example of the current JSON format:
{
"一": {
"strokes": 1,
"grade": 1,
"freq": 2,
"jlpt_old": 4,
"jlpt_new": 5,
"meanings": ["One","One Radical (no.1)"],
"readings_on": ["いち","いつ"],
"readings_kun": ["ひと-","ひと.つ"],
"wk_level": 1,
"wk_meanings": ["One"],
"wk_readings_on": ["いち","いつ"],
"wk_readings_kun": ["!ひと"],
"wk_radicals": ["Ground"]
},
"二": {
"strokes": 2,
"grade": 1,
"freq": 9,
"jlpt_old": 4,
"jlpt_new": 5,
"meanings": ["Two","Two Radical (no. 7)"],
"readings_on": ["に","じ"],
"readings_kun": ["ふた","ふた.つ","ふたたび"],
"wk_level": 1,
"wk_meanings": ["Two"],
"wk_readings_on": ["に"],
"wk_readings_kun": ["!ふた"],
"wk_radicals": ["Two"]
},
}
And the format I eventually wish to achieve is the following:
[
{
kanji: "一",
strokes: 1,
grade: 1,
freq: 2,
jlpt_old: 4,
jlpt_new: 5,
meanings: ["One","One Radical (no.1)"],
readings_on: ["いち","いつ"],
readings_kun: ["ひと-","ひと.つ"],
wk_level: 1,
wk_meanings: ["One"],
wk_readings_on: ["いち","いつ"],
wk_readings_kun: ["!ひと"],
wk_radicals: ["Ground"]
},
{
kanji: "二",
strokes: 2,
grade: 1,
freq: 9,
jlpt_old: 4,
jlpt_new: 5,
meanings: ["Two","Two Radical (no. 7)"],
readings_on: ["に","じ"],
readings_kun: ["ふた","ふた.つ","ふたたび"],
wk_level: 1,
wk_meanings: ["Two"],
wk_readings_on: ["に"],
wk_readings_kun: ["!ふた"],
wk_radicals: ["Two"]
}
]
As you can see, the initial format has a key describing each object, but the aspired format has every info inside the object.
It would be awesome if someone could help me out on this problem! :)