05-16-2021 03:32 AM
I am trying top parse some annoying JSON. There are two issues with it...
1) The top level JSON is an array, but each element might have different elements. I'd like to specify a superset of elements in my cluster, but the NI function errors when you have an element that's not in the JSON.
2) The JSON looks vaguely like this:
[{
"deviceId":012345,
variables: {
"randomName1":"int",
"randomName2":"String",
"randomNameX":bool
},
{
"deviceId":543210,
variables: {
"randomName5":"dbl",
"randomName17":"String"
}]
The "variables" element is a list of pairs, but the element names are unique and random. Kind of like if they were just listing the name:height of people in a classroom. I don't know what the names are. I would like to parse this into a 2D array of strings (or whatever element makes sense, even variant properties or a map, etc.)
I tried to use the path in the NI function, but you either need to name the element or its position in an array; These are unknown names in a list.
Any ideas?
Solved! Go to Solution.
06-02-2021 09:49 AM
Are you getting any errors? How is the system behaving?
06-02-2021 11:06 AM
I found a solution on lavag.org
https://lavag.org/topic/22048-using-jsontext-to-parse-a-poorly-formatted-json-string/?tab=comments#c...