I have a set of values in my db. After reading that, my output will be like below.
FetchValues =
[{
"Key": "123"
"Value":"aa"
"Type":"A"},
{},
{}
]
I need to form a dynamic json array like below after fetching the values from DB.
{
"A":{
"123" : "aa"
},
{
"B": {
"124" : "bb"
}
}
var Json = {}
for(k=0;k<fetchValues.length;k++)
{
Json.push({ fetchValues[k].Type
: {
fetchValues[k].Key : fetchValues[k].Value
}
})
But it gives error. Kindly help on this.