JSFiddle - React, Tailwind, and code Playground
JavaScript
var items = [
{
"Id":{
"LValue":1,
"Value":1
},
"Date":{
"LValue":"2013-10-17T00:00:00",
"Value":"2013-10-24T00:00:00"
},
"User":{
"LValue":508,
"Value":507
},
"Comments":{
"LValue":"This a test load",
"Value":"This a test"
},
"Name":"John Doe",
"IsDeleted":false
}
];
var flattenedItems = items.map(function(x) {
var flattened = { LValues: {} };
for (var prop in x) {
flattened[prop] = x[prop].Value;
flattened.LValues[prop] = x[prop].LValue;
};
return flattened;
});
console.log(flattenedItems);
console.log(JSON.stringify(flattenedItems));