I have this json I need to format it in Typescript or java script. what would be better way to do.
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"
}
}
Need Output like this
{
{
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 tried
var new = [];
Var values = Object.keys(data)
values.ForEach(Function(value){
new.push({
'value' : value })
});
and iterate it, but could not get desired output. I tried to flatten this but I got objects like {value : value , { type: String ,Description : abc}} What should I do to solve it
value 1,value 2etc inputs, and no space in the output example. And you do not explain such a data mutation.