02-24-2012 07:30 AM
@Philmod wrote:
Hi Steve,
I wrote some code, but I still have some problems:
- I would like to use the cluster2json vi recursively if there are clusters inside the main cluster, but how I can get back the clusters from the variant?
- What kind of input variable I have to use in cluster2json in order to use any kind of cluster (and not a defined type)?
Regards,
Philippe
For the second question, you need your subVI to take a control reference in and not the actual cluster. From the calling VI you would right click on a cluster and create a reference. Wire that reference to your cluster2json VI. The easiest way to create the control is to right click on the green Controls[] wire and select create control. Delete your cluster and it's property node and instead wire the new control to the loop.
For the first question you could make the subVI reentrant under execution/properties. In your "cluster" case you place an instance of itself inside. You would wire the reference out from the property node on the left of the case structure to this instance. You also need a property node for the name of the cluster (text/label).
Let me know if you have any questions.
02-24-2012 07:47 AM
You also need a to more specific class. Like this
02-24-2012 12:39 PM - edited 02-24-2012 12:44 PM
I redid some stuff in your VI. One point that is not really related to your problem is about connector panes. I really don't like to change from the default connector pane. I also like to pass references through VIs. I don't mind unused connectors. It is always a pane (pun?) when I want to add a control or indicator and have to change the connector pane and relink. Enough about that ![]()
I changed your array2json so that it will be able to determine the type of array. Right now it only has a case for DBL but you can add one for string. See the Test cluster2json VI that I added.
Edit: This also does not escape the special characters for strings as defined at http://json.org.
02-27-2012 03:15 AM
Thank you so much Steve!!
But I didn't catch you about the special characters espacing for strings. I implemented: \ --> \\ and " --> \". I have to do the same for the LabView backspace, newline, carriage return, tab, ... ?
02-27-2012 10:54 AM
I don't know if you're familiar with Github, but I push the library there (https://github.com/Philmod/Labview-JSON). It will be easier to contribute to the VIs.
02-27-2012 12:47 PM
Yes, that's what I mean. Here is a VI, but it doesn't support escaping unicode.
04-17-2012 03:09 PM
Stumbled across this thread while researching JSON with Labview. I might have use for something like this for websockets but I need it to work in Labview Real-Time. The code posted on Github would have to be refracting to a value based approach instead of control referenced based. Labview Real-Time does not support control references. Any objections to me contributing to this code and making it work for Labview Real-Time?
04-18-2012 01:32 AM
I would be interested in your solution!
04-18-2012 04:32 AM
@dwisti wrote:
Stumbled across this thread while researching JSON with Labview. I might have use for something like this for websockets but I need it to work in Labview Real-Time. The code posted on Github would have to be refracting to a value based approach instead of control referenced based. Labview Real-Time does not support control references. Any objections to me contributing to this code and making it work for Labview Real-Time?
Just to repeat my previous suggestion: make sure you peruse the "OpenG LabVIEW Data Tools" as they make stuff like this pretty easy. And they work on Real Time.
-- James
04-18-2012 08:04 AM
James,
I totally agree. I don't think I would be able to "not" use OpenG to produce a value based solution.
David