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"
]
}
]
}
太感謝你了。!這是完美的。!! –