Jump to content

Recommended Posts

  • 2 months later...
On 7/9/2020 at 5:39 AM, Porter said:

Bug? JSONText doesn't apply input default values to missing cluster items of array elements.

image.png.cfac8c824a0c9d7cb52ca3a937cbf166.pngimage.png.8ae1b813f1c246373cf99f02b3bc8356.png

I was hoping to see "Default", 1 and "2", NaN but instead get "",1 and "2",0

I think that it is due to the behavior of the Get Array Information VI.

The workaround is to convert the array elements individually as clusters:

image.png.30316820d66dc9e23dc0c3ae7f3760c8.pngimage.png.4022f34cc2d9604696e4e09bf7fe0789.png

Note: you can also do this (using the JSONpath for all array elements) because here one is specifying the element of the array (with default) rather that an empty array:

254981577_2020-09-2315_44_57-Untitled1BlockDiagramonJSONtext.lvproj_MyComputer_.png.1c8917c4a3694ddfabfb593626f8e9f3.png

  • Thanks 1
Link to comment
  • 5 weeks later...
4 hours ago, Jordan Kuehn said:

It appears that the JSON parser built into NXG WebVIs is incapable of reading enums or timestamps. I am not certain if that is a limitation of the parser or the encoder.

The "Flatten to JSON" and "Unflatten from JSON" nodes in NXG WebVIs are essentially the same as the ones built into classic LabVIEW. Both are incapable of processing enums or timestamps.

As a workaround, you can create a "bridging" typedef (GType) which replaces enums and timestamps with strings. Use that with the NXG JSON parser, and then convert it to your "real" GType.

Link to comment
16 minutes ago, JKSH said:

The "Flatten to JSON" and "Unflatten from JSON" nodes in NXG WebVIs are essentially the same as the ones built into classic LabVIEW. Both are incapable of processing enums or timestamps.

As a workaround, you can create a "bridging" typedef (GType) which replaces enums and timestamps with strings. Use that with the NXG JSON parser, and then convert it to your "real" GType.

Thank you for the confirmation. I have done something similar using numeric types, but it is inconvenient at best. An NXG version of this toolkit would be fantastic. 

Link to comment
1 hour ago, Jordan Kuehn said:

Thank you for the confirmation. I have done something similar using numeric types, but it is inconvenient at best. An NXG version of this toolkit would be fantastic. 

Unfortunately, the NXG Web module lacks both recursion and VIs for determining the data type inside a variant.  This makes porting JSONtext to it very difficult.

Link to comment
  • 3 weeks later...
  • 2 months later...
11 minutes ago, drjdpowell said:

Not sure I understand the question.  Can you rephrase it?

I have a request from non-LV programmers who are using the JSON output I am providing them to provide the schema so that they can ensure they are accurately parsing the data structure. I have used a tool similar to this: https://www.liquid-technologies.com/online-json-to-schema-converter to generate it, but it is imprecise. I’d prefer to just give them the typedef file, but they have no idea what to do with that. 

Link to comment
1 hour ago, Jordan Kuehn said:

I have a request from non-LV programmers who are using the JSON output I am providing them to provide the schema so that they can ensure they are accurately parsing the data structure. I have used a tool similar to this: https://www.liquid-technologies.com/online-json-to-schema-converter to generate it, but it is imprecise. I’d prefer to just give them the typedef file, but they have no idea what to do with that. 

Ah, you mean this then: http://json-schema.org/understanding-json-schema/, and you want a function that converts a LabVIEW Cluster/Array to a basic JSON Scheme.  

That does not exist in JSONtext but could at some point.  

 

  • Like 1
Link to comment
1 hour ago, Antoine Chalons said:

Would it be possible to add support for maps / sets - as if they were arrays - ?

I can really remember if they were added in LV 17 or 18 or 19....

Sets and Maps were added in 2019.  But just to throw a wrench into your dreams, you can get some interesting combinations when it comes to sets and maps.  You could have a set of maps.  You could have a map with a set for a key.  I'm just saying, you would have to plan this out very carefully.

Link to comment
22 minutes ago, crossrulz said:

Sets and Maps were added in 2019.  But just to throw a wrench into your dreams, you can get some interesting combinations when it comes to sets and maps.  You could have a set of maps.  You could have a map with a set for a key.  I'm just saying, you would have to plan this out very carefully.

Very true!!

I do use nested combinations of set and map - not hugely deep but it does turn out to be very useful.

And yes it might not be trivial to handle ALL possible cases.

But let's engineer ambitiously, no?

Link to comment
  • 1 month later...

Is there any way to simply get the keys or have the json structure convert into a cluster?  I've tried using the "find multiple items.vi", but nothing shows.  No errors either.

83424669_2021-03-1712_00_42-jsonparser.viFrontPanel1_.png.84c6e6c19c8658d0196044f4cf13faf5.png

 

I've also tried using "Get all objects items.vi" but looks like I have to guess at the offset and do a recursive loop.

204629551_2021-03-1712_05_26-jsonparser.viFrontPanel2_.png.82f67d56f64379b5dfcabfab90d3fb4d.png

Thank you,

Ron

Link to comment

Join the conversation

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

Guest
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.