10-18-2022 01:26 PM
I'm attempting to use a map with variant data for a configuration database and tried using the LabVIEW XML Schema for simplicity, however the "Untlatten from XML" method seems to crash LabVIEW when using this data type. Is this a known issue? If so, is there a workaround?
Version 22.3.1f8 (32-bit)
Solved! Go to Solution.
10-18-2022 01:33 PM
Have you considered flattening your data to a string and then mime encode it. That would be a little overhead but should be safe for XML and JSON. Not sure how XML deals with binary data which you will end up encountering using variants.
10-18-2022 01:54 PM
Not sure I follow. Are you suggesting to flatten the entire map of variants or to use a map of flattened strings? Also you lost me on mime encoding. The goal is to have a map of variants (using variant attributes) saved to a human-readable config file.
10-18-2022 02:16 PM
A variant will not be human readable and will contain binary data. If you want it to be human readable your only real option is to have everything a string. You would need to convert your numeric data to ASCII and then save to file. Also, if you want to have humans read it JSON is easier to work with then XML in my opinion. However you will have the same problem there as well.
What I was suggesting was to replace your variant with a string. Then flatten your data to a string and then do a base64 encoding of that string. Neither XML or JSON deal with binary data very well not to mention that binary data is not very human readable.
If you want to stick with flatten to XML or flatten to JSON then I suggest you create a cluster definition for the data you want to store to file and then flatten that.
10-18-2022 02:23 PM - edited 10-18-2022 02:24 PM
Binary data will not be human readable, no. But all simple data types I will be using (numerics, strings, booleans, enums, arrays, etc.) work fine. Variant attributes seem to work fine with the XML schema as of LabVIEW 2020; I was hoping to leverage maps in addition to that.
10-18-2022 02:26 PM
Then I would suggest converting your map to an array and then flatten the data.
10-18-2022 03:02 PM - edited 10-18-2022 03:07 PM
An array seems to work fine. Not sure why the Map has issues, but the following snippet serves mostly the same functionality and doesn't crash.
10-18-2022 03:11 PM
Just curious why you marked your post as the solution when it was I that suggested it. At least give credit where credit is due.