我有一个由旧服务器返回的对象,我想通过 JavaScript、jQuery 甚至 Underscore.js 更改客户端的结构。
下面是我的原始对象的样子:
[
{
"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
}
]
不过,在客户端,我想将其展平以获取“值”并将“LValues”填充到单独的属性中,以便以后需要时不会丢失它们:
[
{
"Id":1,
"Date":"2013-10-24T00:00:00",
"User":507,
"Comments":"This a test",
"Name":"John Doe",
"IsDeleted":false,
"LValues": {
"Id":1,
"Date":"2013-10-17T00:00:00",
"User":508,
"Comments":"This a test load"
}
}
]
这将使使用该对象变得更加容易,任何帮助将不胜感激!