JSON Toolkit for LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Known Issue Parsing Arrays in JSON Toolkit

When you parse JSON text that contains an array, then you have to treat it as a JSON Array. You cannot use the 1D Array functions for parsed JSON text.

The following example shows how you can use the 1D Array functions to generate a JSON string but how you must use the JSON Array functions to access the array values:

i3jsonarraybehavior.png


Milan
0 Kudos
Message 1 of 5
(9,292 Views)

hi Milan,

 

I hace two questions:

1) to get an array datas, your way works, however should work directly also following the picture attached, but I have found parsing problems... why?

 

2) if I would like to write/read a 2D array, how would I have to do?

 

thanks

 

dh

 

 

0 Kudos
Message 2 of 5
(7,307 Views)

Hi dh,

 

For question 1, unfortunately I cannot see the included image. It seems to not be attached correctly.

 

For question 2, the i3-json toolkit does not support 2D arrays directly. When parsing you have to use the API functions to read an Array of Arrays by index in nested for-loops. When generating 2D arrays you can improve performance a bit by creating Arrays of 1D Numeric Arrays. The following snippet shows both patterns.

2D Arrays with i3-json.png

 

 

 


Milan
0 Kudos
Message 3 of 5
(7,286 Views)

Hi Milan,

 

thank you for your reply.

Your example works (and in some way it replies also to the question number 1!)... however I have two new questions.

1) how I can include also array with more than two dimensions? I tried in the same way, but it generates an error (also the json string is wrong... it seems a 2d array) (screenshot in attach and test_json_5.vi)

2) how can I pass the Tree ref in a subvi? I tried but it also generates an error (I send you a screenshoot file, where the ctrl ref is pane to "JSON Tree Out Passthrough" just after "Parse Json.vi")

 

Moreover, I'm trying to include on a more complex json based on clusters... and I have some problems. It is better to send also all the files

 

thank you

 

dariush

0 Kudos
Message 4 of 5
(7,235 Views)

Hi Milan,

 

following your example I found a bug, but I cannot find the right solution.

In the attached example, I red the 2D array in an explicit way (following the JSON Tree) and implicit way (parsing the Json string)

However, in the second case all is ok, while in the first one I cannot read the array... where is my mistake?

 

dh

 

 

Download All
0 Kudos
Message 5 of 5
(7,114 Views)