LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reordering JSON data

Solved!
Go to solution

Hello all

I need help reordering Data I get from an Unflatten from JSON.
I have a JSON string from an API call (from unflatten from JSON) that contains a name (string), a numeric, and a Channel (also a string).  
The Unflatten from JSON automatically orders the data it receives in the order the data is provided.  The data is information about channels.  The problem arises when not all channels are provided.  If out of 12 channels, the JSON receives information on only 4 channels, it orders them 1 through 4 in the array.  However, 1 may not correspond to channel 1 and may in actuality be channel 5 and 3 may not correspond to channel 3 so on and so forth.  I would like to reorder the JSON based on the channel reading (a string named Channel).  So if in the array Channel 4 is actually 12 (based on string channel, i.e. Channel-12), I would like to connect Channel 4 data into channel 12 in a new array so that the ordering of the channels remains dependent on the channel string and  not based on the order from unflatten from JSON.

Please help as I am out of ideas on how to solve this.

Thank you.

0 Kudos
Message 1 of 3
(3,122 Views)
Solution
Accepted by topic author DRH

Is this what you ment?

PS: Try to avoid mutliple index array - it's better to use arrays and for loops;)

0 Kudos
Message 2 of 3
(3,094 Views)

Thank you Adam

0 Kudos
Message 3 of 3
(3,086 Views)