Я пытаюсь сделать формат JSON из данного JSON
Я использую функцию карты в nodejs, но она работает неправильно. Я даю все детали здесь. Я хочу код, который даст мне необходимый формат JSON.
Учитывая Джсон:
var x =
[
[
{
"title":"My feel about shape up",
"answer":"neutral",
"objectives":[
"Awareness"
]
},
{
"title":"How good is shape up ?",
"answer":"a",
"objectives":[
"Awareness"
]
}
],
[
{
"title":"My feel about shape up",
"answer":"neutral",
"objectives":[
"Awareness"
]
},
{
"title":"How good is shape up ?",
"answer":"Awareness",
"objectives":[
"Awareness"
]
}
]
];
Код, который я пробовал:
result = x.map(function(subarray) {
var data = subarray.map(v =>{
const wd= {[v.title ]: v.answer}
return wd;
})
return data;
})
Фактическая выработка:
[ [ { 'My feel about shape up': 'neutral' },
{ 'How good is shape up ?': 'a' } ],
[ { 'My feel about shape up': 'neutral' },
{ 'How good is shape up ?': 'Awareness' } ] ]
Ожидаемый результат:
[
{ 'My feel about shape up': 'neutral',
'How good is shape up ?': 'a' } ,
{ 'My feel about shape up': 'neutral',
'How good is shape up ?': 'Awareness' }
]