1
需要遍历下面的JSON对象并形成具有唯一数据的结果json。结果将基本上由问题列表及其选择组成。请帮助我。提前致谢..!!删除JSON中的重复对象并形成数组
var data = [
{
"category": "sports",
"question": "Who is the best footballer?",
"questionType": "text",
"choices": "Messi",
"name": "Best Footballer",
"createdUserId": 1
},
{
"category": "sports",
"question": "Who is the best footballer?",
"questionType": "text",
"choices": "Ronaldo",
"name": "Best Footballer",
"createdUserId": 1
},
{
"category": "sports",
"question": "Who is the best footballer?",
"questionType": "text",
"choices": "Ibrahimovic",
"name": "Best Footballer",
"createdUserId": 1
},
{
"category": "sports",
"question": "Who is the top goal scorer?",
"questionType": "text",
"choices": "Messi",
"name": "Best Footballer",
"createdUserId": 1
},
{
"category": "sports",
"question": "Who is the top goal scorer?",
"questionType": "text",
"choices": "Ronaldo",
"name": "Best Footballer",
"createdUserId": 1
},
{
"category": "sports",
"question": "Who is the top goal scorer?",
"questionType": "text",
"choices": "Lewandoski",
"name": "Best Footballer",
"createdUserId": 1
}
];
JSON填充
{
"name": "Best Footballer",
"category": "sports",
"createdUserId": "1",
"questionList": [
{
"question": "Who is the best footballer?",
"questionType": "text",
"choices": [
"Messi",
"Ronaldo",
"Ibrahimovic"
]
},
{
"question": "Who is the top goal scorer?",
"questionType": "text",
"choices": [
"Messi",
"Ronaldo",
"Lewandoski"
]
}
]
}
太感谢你了。!这是完美的。!! –