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.
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.
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.
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.
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.
Then I would suggest converting your map to an array and then flatten the data.
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.
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.