11-28-2014 02:26 AM
Hi! I'm making a SubVI that takes some input data, turns it into JSON, and sends it to a server following some predetermined convention (HTTP REST). The very nice thing about the builtin JSON nodes is that they take "anything" as input, and I'd like to wire that input directly outside of the SubVI. When I right click on the "Anything" input and then "Create Control", though, an empty cluster turns up, and if I try to use that as input, the SubVI will actually want an empty cluster and not anything.
Solved! Go to Solution.
11-28-2014 02:32 AM - edited 11-28-2014 02:32 AM
11-28-2014 02:58 AM
Thanks, I'm not sure how to go about that though. The Flatten to JSON node doesn't accept Variant Controls as input, nor does it accept the LabView-data conversion of that control.
Sorry if it seems that I want a readymade answer, I just don't know where to look for a solution to this.
12-01-2014 02:44 AM
Hi Francesco,
reading the Flatten to JSON function hel, you need to use the following data type:
This input accepts arrays and clusters of Booleans, floating-point numbers, and strings. anything can also accept an array of clusters, or a cluster of arrays, of these data types.
Try to format data in the right way.
Kind regards.
Cla_CUP
NI Italy
AE Dept.
12-01-2014 03:15 AM - edited 12-01-2014 03:16 AM
That's a shame that it doesn't accept a variant input (like xml, configuration, variant attribute VIs etc.)...it means you can't easily wrap it in a SubVI...
As for the topic of this post - you could look at one of the 3rd party JSON toolkits...there are a few floating about and they will likely accept a variant as the input.
12-01-2014 04:08 AM
Thanks Cla_Cup and thanks Sam_Sharp.
In the end I decided to avoid the problem altogether and to leave the FlattenToJSON node out of the SubVI. I instructed my client to insert a snippet containing the FlattenToJSON node linked to the SubVI node instead of just the SubVI node. That just seemed like a cleaner solution, I didn't want to download third party libraries to replicate a function that LabView already has.