Jump to content

Extracting values from JSON


Recommended Posts



I am having difficulties with extracting JSON messages and since this is my first time to deal with JSON extracting in LabVIEW, I am not sure whether it is possible to solve it and how.

Now, JSON input is something like this:


You can see that I can have mixed object items: one "value1", repeated (multiple) "value2", one "value3", missing "value4" and then "value5"...

Any object item can be multiplied or missing in different messages I receive.

My question is how to extract repeated object items and plot them on a XY graph? To be more precise, if I get no item in a message - I should keep the old values (not to have drop to zero on a graph), if I get one item, I should just plot it and if I get multiple items in a message, I should plot all of them on a graph.

This is what I did so far. It plots and keeps old values if nothing received but I have problem extracting multiple values.


I would appreciate any hint or help.


Thanks in advance,


Link to comment
Share on other sites

  • 2 weeks later...

Hello Jim,

Thank you for response and effort. I've actually tried before similar approach but eventually gave up because of another problem. Maybe you could help solving that.

In order to plot on different graphs, I have to separate the output array into several arrays - separate array for every value. 
But as the JSONs on input differ from message to message, things are getting a bit more complicated because array size and positions of the values are constantly changing. The only solution I could think of is using index array function and some logic based on Item Names output from Get All Object Items VI to extract data from one combined array that we have in current VI. I guess I would have to copy that method for every value so it would be pretty nasty and I don't have a good feeling regarding optimization using method like that? Maybe there is a more elegant solution for that?
In attachment, you have the VI in which I have simulated three different JSON messages I could expect on input, going into the code you have suggested. Would be grateful if you could take a look.

Thanks in advance.

JSON Test.vi

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.