LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HELP Convert JSON string to LabVIEW cluster of arrays.

Solved!
Go to solution

JSON String:

 

{"Results00":[["2467760","4455879","5","0",""]],"Results01":[],"FldNms00":["ResultSetID","ResultValueID","CurrentInterval","OffBottomn","IDPrelog"],"FldNms01":[],"ErrMsg":["FALSE-0-"]}

 

That string was flattened from this data cluster of 2D and 1D arrays:

 

                                  cluOfArrays.png

I am trying to Unflatten back to the data cluster with no luck using this LabVIEW JSON to LabVIEW Object tool.

 

                    cluOfArrays01.png

But this solution on gives the 1st 2D array.

 

                      cluOfArrays02.png

As seen above only the 1st 2D array was parsed.

 

Can anyone please help parse the rest.

 

Anthony Lukindo

 

 

 

 

0 Kudos
Message 1 of 6
(1,056 Views)
Solution
Accepted by topic author Anthony_L

The problem is that in the JSON string, "Results01" is one dimensional (Results01":[]), but in the LabVIEW cluster it is two dimensional.  If you change the JSON string to ...Results01":[[]] ... it works.

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 6
(1,027 Views)

Wow!

 

Thanks!  The issue is with LabVIEW JSON Flatten LVObject to string JSON string.

 

So, the same cluster data was fed but it looks like if the Results01 2D array is empty, that function send an Empty 1D array instead!

 

I will get around this by sending a default 2D Blank array from the other end.

 

Thanks much.

 

0 Kudos
Message 3 of 6
(1,016 Views)

I just realized that LabVIEW tool for converting LVObject to JSON string needed that I set the following to TRUE

 

Boolean = TRUE (for LabVIEW extensions).  See below:

 

cluOfArrays03.png

 

Now the string becomes LabVIEW compatible and can be parsed back to same LV Object correctly using the UNFLATTEN VI. 

 

 

Just as Paul_Cardinale pointed out in the ACCEPTED solution. 

 

 

 

Message 4 of 6
(1,008 Views)

That TRUE Boolean did not work! I had to do this, where I replace the [] with [[]] For the Results00 and Results01 outputs.

 

cluOfArrays04.png

Sheesh! I had to escape the '[' and ']' characters because they have a special meaning in LabVIEW when matching strings.

0 Kudos
Message 5 of 6
(997 Views)

What LV are you using? An empty 2D string array is correct in my 2019.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(802 Views)