LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Arun_Persaud

Allow enums in "flatten to json"/"unflatten from json"

Status: New

Currently enums can not be in a cluster that you want convert to JSON. It would be great, if this could be added.

 

Either the enum value could be converted to its internal representation (e.g. u16) or the value could be saved as a string (make it easier to read the JSON and parse it outside LabVIEW).

 

The unflatten should be able to handle the u16 easily to convert back to enum or take the string and search through the enum of the datatype that one has to connect to the vi. If there is no match the VI can issue an error.

 

3 Comments
malocascio
Member

I just ran into this issue myself. It makes it difficult to introduce JSON serialization into any existing code that includes enums in clusters.

 

The unflatten/flatten JSON VIs could just include an input terminal that allows you to specify whether you want enums to be encoded as their integer value or their string.

jwscs
Active Participant

letting ppl have the option to either have the selected number or the string (with defaulting to string) would be my preference.

 

i use the to-json serialization (or would like to) for my logging

 

the xml just spams all info, which makes it unusable for me ther

(especially if you have many cases in the enum)

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Tomi_Maila
Active Participant

JKI JSON library allows flattening and unflattening enums to both numbers and strings.

 

jki.net/tools#json

--
Tomi Maila