After changing the key name in the Json Array, it should be combined with other Json Arrays.

Asked 2 years ago, Updated 2 years ago, 76 views

To draw a multi-line arm chart

A total of four types of JsonArray must be combined. In addition, the key names of the four JsonArray are duplicated, so xx1, xx2, and... and so on It is not easy because my skills are not good enough to combine with one Json Array.

Each Json Array has its own size.

[ { avg : 1234, hour : "20180101000000" }, { avg : 5678, hour: "20180102000000" } . . . ]

Json Array's four avgs that look like this, avg1, avg2... For "Low hour", change it to "date" [ { avg1: 1234, avg2: 5678, avg3: 9012, avg4: 3456, date: "20180101000000" }, { avg1: 7890, avg2: 5558, avg3: 9812, avg4: 3326, date: "20180102000000" }, . . . ]

We need to create this data... Each data is received using API, so you have to change it and combine it first.

Tell me the way...

No progress has been made in days...

The language is Java or JavaScript.

json jsonarray jsonobject merge

2022-09-21 23:03

1 Answers

What's the difficulty? It doesn't require complicated technology.

All you have to do is get the rules right.

L = [{avg : 1234, hour : "20180101000000" }, {avg : 5678, hour: "20180102000000"}]
[{'avg1':L[0].avg, 'avg2':L[1].avg, 'date':L[0].hour}]

Json itself is a javascript object, so you can use it right away.


2022-09-21 23:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.