How js merges N similar JSON into one

because of my lack of experience in data processing, I will be confused when I encounter similar problems. I hope God can help me answer my question. Thank you.
is described as follows:
1. At present, there are more than N json data, which are returned from the interface, and do not know how much this N is
2. The returned JSON data have one thing in common, that is, the title is the same, while different title need to be merged into another new data, as follows

clipboard.png
the title of 4 of the five JSON, in the figure is consistent, and only the last one is independent. The final data structure is as follows

[
    {
        title: "",
        details: [
            {
                page: {
                    from: 28,
                    to: 29
                },
                time: "2018-3-12 15:45",
                type: ""
            },
             {
                page: {
                    from: 28,
                    to: 29
                },
                time: "2018-3-12 15:45",
                type: ""
            },
             {
                page: {
                    from: 28,
                    to: 29
                },
                time: "2018-3-12 15:45",
                type: ""
            },
        ],
        snippet: [
            "",
            "",
            ...
        ]
    },
    {
        title: " (xiao)",
        details: [
            {
                page: {
                    from: 2770,
                    to: 2771
                },
                time: "2018-5-10 10:25",
                type: ""
            }
        ],
        snippet: [
            ""
        ]
    }
]

data processing Xiaobai thanks God for his reply. I hope he won"t complain about me. Thank you

Mar.24,2021

create a MAP, with TITLE as KEY,. If you find the specified KEY, in MAP, take out the corresponding data, merge the details array, and add the current record if it is not found. When you are finished, convert the MAP into an array. If you want to keep the original order, create an array while creating the MAP to maintain the order. Pay attention to the Synchronize of the MAP and the array.

think about the above ideas first, and I'll fill in the code later

< hr >

you have to restore your original data first. Next time you ask a question, remember to post the original data


:json<br>:njson

//
var arrList = [];
//
for(var i of arrList.keys()){
    if(arrList[i].title == json.title){
        (arrList[i].detail).push(json.detail)
    }else{
        var j = arrList.length;
        arrList[j].title = json.title
        arrList[j].detail = [];
        (arrList[j].detail).push(json.detail)
    }
}
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-1b3afed-2b5bf.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-1b3afed-2b5bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?