Looking for help with formatting JSON in Typescript or JavaScript. Which approach would be better?
var data = {
"value 1" : [
{
type : String,
Dicription : "abc"
},
{
type : int,
Dicription : "xyz"
},
{
type : String,
Dicription : "pqr"
},
]
"value 2" : [
{
type : String,
Dicription : "abc"
}
]
"value 3" : [
{
type : String,
Dicription : "abc"
},
{
type : int,
Dicription : "xyz"
}
}
Desired Output:
{
{
value : value1,
type : String,
Description : "abc"
},
{
value : value1,
type : int,
Dicription : "xyz"
},
{
value : value1,
type : String,
Dicription : "pqr"
},
{
value : value2,
type : String,
Description : "abc"
},
{
value : value3,
type : String,
Description : "abc"
},
{
value : value3,
type : int,
Description : "xyz"
}
}
I attempted to iterate through the data but couldn't achieve the desired output. I tried to flatten it, but got objects like {value : value, {type: String, Description : abc}}. Any suggestions on how to solve this?