How to use map and Object.assign to convert data into the format you want

Figure 1 is the data structure returned to me by the backend

Figure 2 is the html part

Figure 3 is the js part, the data format I want is as follows, and it will be rendered according to this data format

Now start to process the data and convert the obtained data into the data format I want. Before getting the data, I need to pass the parameters in the address bar, and the parameters are passed through the interface, so the data is directly spliced ​​​​to the back of the interface. Here only The screenshot shows the data processing of name and obj1. The rest of obj2-4 are the same as obj1. Now name and obj1-4 are all separate json.

Put the above separate json into an array

 

Guess you like

Origin blog.csdn.net/qq_47599989/article/details/128067658