How to reorganize the json data and classify them according to the type of test questions?

the final rendering to the page is based on single selection, multi-selection, judgment, etc., to solve?

[
    {
        "createTime": "2018-03-31 18:54:48",
        "enable": "1",
        "keyword": "",
        "orderBy": "",
        "paperId": "10",
        "question": {
            "courseName": "",
            "createBy": "1",
            "createTime": "2018-03-10 14:15:34",
            "enable": "1",
            "id": "2",
            "keyword": "",
            "options": [
                {
                    "createTime": "2018-03-10 14:15:34",
                    "enable": "1",
                    "id": "5",
                    "keyword": "",
                    "optionCode": "A",
                    "optionText": "",
                    "orderBy": "",
                    "questionId": "2",
                    "remark": "",
                    "updateTime": "2018-03-10 14:15:34"
                },
                {
                    "createTime": "2018-03-10 14:15:34",
                    "enable": "1",
                    "id": "6",
                    "keyword": "",
                    "optionCode": "B",
                    "optionText": "",
                    "orderBy": "",
                    "questionId": "2",
                    "remark": "",
                    "updateTime": "2018-03-10 14:15:34"
                },
                {
                    "createTime": "2018-03-10 14:15:34",
                    "enable": "1",
                    "id": "7",
                    "keyword": "",
                    "optionCode": "C",
                    "optionText": "",
                    "orderBy": "",
                    "questionId": "2",
                    "remark": "",
                    "updateTime": "2018-03-10 14:15:34"
                },
                {
                    "createTime": "2018-03-10 14:15:34",
                    "enable": "1",
                    "id": "8",
                    "keyword": "",
                    "optionCode": "D",
                    "optionText": "",
                    "orderBy": "",
                    "questionId": "2",
                    "remark": "",
                    "updateTime": "2018-03-10 14:15:34"
                }
            ],
            "orderBy": "",
            "questionAnswer": "ABD",
            "questionTitle": "

", "questionType": "2", "remark": "", "updateBy": "1", "updateTime": "2018-03-10 14:15:34" }, "questionAnswer": "", "questionId": "2", "remark": "", "score": "5.00", "updateTime": "2018-03-31 18:54:48" }, { "createTime": "2018-03-31 18:54:48", "enable": "1", "keyword": "", "orderBy": "", "paperId": "10", "question": { "courseName": "", "createBy": "1", "createTime": "2018-03-26 11:35:41", "enable": "1", "id": "5", "keyword": "", "options": [], "orderBy": "", "questionAnswer": "", "questionTitle": "

1840

", "questionType": "4", "remark": "", "updateBy": "1", "updateTime": "2018-03-26 11:35:41" }, "questionAnswer": "", "questionId": "5", "remark": "", "score": "5.00", "updateTime": "2018-03-31 18:54:48" }, { "createTime": "2018-03-31 18:54:48", "enable": "1", "keyword": "", "orderBy": "", "paperId": "10", "question": { "courseName": "", "createBy": "1", "createTime": "2018-03-26 11:36:09", "enable": "1", "id": "6", "keyword": "", "options": [], "orderBy": "", "questionAnswer": "1840", "questionTitle": "

", "questionType": "3", "remark": "", "updateBy": "1", "updateTime": "2018-03-26 11:36:09" }, "questionAnswer": "", "questionId": "6", "remark": "", "score": "5.00", "updateTime": "2018-03-31 18:54:48" } ]
Feb.28,2021

do you mean to sort by .room.sorting Type ?

suppose there is a variable questions in the array you give, and collection

is sorted.
var collection = {};

questions.forEach(ques => (collection[ques.question.questionType] = collection[ques.question.questionType] || []).push(ques));

write separately and read more clearly

var collection = {};

questions.forEach(ques => {
  collection[ques.question.questionType] = collection[ques.question.questionType] || [];
  collection[ques.question.questionType].push(ques);
});

I think you want to traverse it for different questionType processing?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9fda1-47852.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9fda1-47852.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?