JSON Toolkit for LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

JSON Toolkit Support for LabVIEW 2010

Is JSON toolkit available in LabVIEW 2010?

0 Kudos
Message 1 of 6
(18,038 Views)

Hi Venkateshcompala,

Like Haris mentioned, to use the NI supported LabVIEW json primitives you need LabVIEW 2013 or later.

The i3 JSON Toolkit in this group was developed in LabVIEW 2011 but should be usable in LabVIEW 2009 and up if back saved.

I went ahead and back saved the current toolkit from LabVIEW 2011 to LabVIEW 2010 and attached it as a zip. I have not tested it at all with LabVIEW 2010 so you may run into some snags. You can give it a try in LabVIEW 2010.

The lava group also has JSON LabVIEW but I believe it also only supports LabVIEW 2011 and up as well.

Best of luck


Milan
Message 2 of 6
(13,365 Views)

Hi Milan,
First of all, thanks very much for quickly converting the json tool kit into labVIEW 2010.
I tried couple of things with this toolkit labVIEW 2010 project, cluster to JSON strings and vice versa,  its working!

Observation:
1)2-D array seems to  be not working, this toolkit throws error. IS 2-D is not supported in JSON?
2)If array size >~700 elements, tool encodes JSON packet faster, but decoding part consumes time. For 1000 elements it consumed around ~4 seconds to parse data from JSON string.Increasing the array length does it degrade the decoding logic?
Attached Test JSON VI, in this input cluster would contain "2-D array of Integer".

Question:
I am planning use this in LabVIEW RT(OS: Phar Lap) to encode/decode JSON packets, can this toolkit VI’s give us the same performance as it runs on windows?
Do I have to update any VI's for doing this?

Thanks for your support!

Venkatesh.C.S

0 Kudos
Message 3 of 6
(13,365 Views)

Hi Venkatesh,

1) In JSON you are allowed to have staggered 2D arrays [ [1], [1,2,3], [2,3] ] which LabVIEW does not support. While it would be possible to specifically add 2D array support, it did not seem like there was a great benefit. You can still create a 2D array by using the 1D array functionality one row at a time, etc.

If your 2D arrays are highly staggered (one row with 1000 elements and one row with 5 elements, etc) then it may even be beneficial to use an array of clusters containing an array [{ "data": [1,2,3,4,5,6,7,8] }, { "data": [1] }  ]

2) Yea the performance of the i3 JSON API for large data sets isn't that great. The reason is that internally the API over uses variant attributes which cause a lot of unneeded memory utilization on parsing. I have plans to overhaul the internal data structures but so far not the time to do it

However, you can squeeze out better performance from the API by usign the lower level parsing VIs. The top level LabVIEW to JSON VI and JSON to LabVIEW VI use the VI Server to analyze the cluster and set values making it significantly slower. I modified the example you provided to show parsing with the low-level api.

Capture.PNG

I did a screenshot because the snipping tool cannot handle the references, but see the attached file for the example

You definitely can use the JSON toolkit on RT targets as I have used the JSON API with Twitter from cRIO controllers. The performance should not be related to the Operating System but in general the embedded RT controllers do not have as much horse power as a modern desktop. If you still have parsing performance problems even with the low-level i3 JSON VIs it may be worth a trying to use the JSON primitives that come with LabVIEW 2013 and greater as they should be much faster.

Milan


Milan
0 Kudos
Message 4 of 6
(13,365 Views)

Hi Milan,

Thanks for your update on how to use low level vi's for array parsing, would let you once i get chance of using it.

Planning to move to LabVIEW 2014, does it comes with inbuilt JSON primitives? or do we need to purchase it seperately. Since i am quite new to JSON, I need your  suggestion on LabVIEW 2014 JSON libraries.

Regards,

Venkatesh.C.S

0 Kudos
Message 5 of 6
(13,365 Views)

Hi Venkatesh,

LabVIEW 2013 and greater (LabVIEW 2013, LabVIEW 2014, etc.) ship with the JSON primitives (they are included with LabVIEW, not a separate toolkit). The VIs that ship with LabVIEW 2013 and up are the Unflatten From JSON VI and Flatten To JSON VI.

And the examples for it can be found by opening LabVIEW 2013 and up, going to Help >> Find Examples, and nvaigating to Fundamentals >> Strings >> Unflatten From JSON.vi.

Best,

Milan


Milan
0 Kudos
Message 6 of 6
(13,365 Views)