JSON Toolkit for LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

JSON file I/O

Hi,

This may sound like a stupid question, but I'll ask it nonetheless:

How do you actually open and read a .json file into Labview? I have the i3 JSON toolkit but all the examples I've seen that use this generate their own data in Labview, not read it in from an existing file. I need to read in the data from a already existing .json file and am getting weird behavior when I try to use the labview file i/o functions. Can you give an example of the sequence of steps to get data from the .json into labview?

Thanks so much,

Fred

0 Kudos
Message 1 of 2
(19,549 Views)

Hi Fred,

As you have seen the JSON VIs in the i3 JSON Toolkit are only able to parse strings. This means that loading a json string from a file will require two steps:

  1. The data in the file can be loaded into a string using the Read from Text File VI. From the documentation you can see that by passing a value less than zero to the count terminal you can load the entire file and it will be output to the text terminal.
    read from file.png

  2. The data from the text terminal can then be passed to the Parse JSON VI and be used with the rest of the JSON Toolkit.
    read from file and parse json.png

One thing to keep in mind when parsing JSON text in LabVIEW 2013 is that now LabVIEW includes native JSON parsing functions which handle many cases. See the following post for some of the JSON parsing options available in LabVIEW: https://decibel.ni.com/content/message/76055#76055

Best,

Milan


Milan
Message 2 of 2
(16,279 Views)