我有一个像
这样的现有JSON模型 var oData = {
{section: "section1",description: "item1 description",checked: true }
{section: "section1",description: "item2 description",checked: true }
{section: "section2",description: "item1 description",checked: true }
{section: "section2",description: "item2 description",checked: true }
{section: "section3",description: "item1 description",checked: true }
}
我试图从现有的json模型
创建这样的结构 var oData = {
{section: "section1"
{description: "item1 description",checked: true } ,
{description: "item2 description",checked: true }
}
{section: "section2"
{description: "item1 description",checked: true } ,
{description: "item2 description",checked: true }
}
{section: "section3"
{description: "item1 description",checked: true } }
}
我正在寻找实现这个目标的最佳方式
答案 0 :(得分:0)
在不知道您想要使用它的方式的情况下确定最佳方法很难但这可能会有所帮助:
var oData = {
sections : [{name: "section1",
items : {
item1 : {description : "description goes here", checked : true},
item2 : {description : "description goes here", checked : true}
}
},
{name: "section2",
items : {
item1 : {description : "description goes here", checked : true},
item2 : {description : "description goes here", checked : true}
}
}
]}