LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parse JSON where an element is a list of key/values, but the key is an unknown name + other issues

Solved!
Go to solution

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?

 

0 Kudos
Message 1 of 3
(2,808 Views)

Are you getting any errors? How is the system behaving?

0 Kudos
Message 2 of 3
(2,703 Views)