there is a comment scenario where id is unique, answerId and id correspond, and answerId is the person who replied to id. You need to convert COMMENT_MOCK_DATA_ORIGIN data into result data structure, which is equivalent to an additional field answerArr into a reply array.
var COMMENT_MOCK_DATA_ORIGIN = [
{
"id": 52,
"a_id": 205,
"user": "3",
"website": "",
"msg": "",
"createTime": "1533303716",
answerId:""
},
{
"id": 54,
"a_id": 205,
"user": "5",
"website": "",
"msg": "",
"createTime": "1533303716",
answerId: 52
},
{
"id": 55,
"a_id": 205,
"user": "5",
"website": "",
"msg": "",
"createTime": "1533303716",
answerId: 52
},
{
"id": 51,
"a_id": 205,
"user": "2",
"website": "",
"msg": "",
"createTime": "1533303713",
answerId: 56
},
{
"id": 56,
"a_id": 205,
"user": "2",
"website": "",
"msg": "",
"createTime": "1533303713",
answerId:""
},
{
"id": 57,
"a_id": 205,
"user": "2",
"website": "",
"msg": "",
"createTime": "1533303713",
answerId:""
},
]
var result = [{
"id": 52,
"a_id": 205,
"user": "3",
"website": "",
"msg": "",
"createTime": "1533303716",
"answerId": "",
"answerArr": [{
"id": 54,
"a_id": 205,
"user": "5",
"website": "",
"msg": "",
"createTime": "1533303716",
"answerId": 52
},
{"id": 55, "a_id": 205, "user": "5", "website": "", "msg": "", "createTime": "1533303716", "answerId": 52}
]
}, {
"id": 56,
"a_id": 205,
"user": "2",
"website": "",
"msg": "",
"createTime": "1533303713",
"answerId": "",
"answerArr": [{
"id": 51,
"a_id": 205,
"user": "2",
"website": "",
"msg": "",
"createTime": "1533303713",
"answerId": 56
}]
}, {"id": 57, "a_id": 205, "user": "2", "website": "", "msg": "", "createTime": "1533303713", "answerId": ""}]
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)