Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

iterate loop through json array

I am having a terrible time trying to iterate a JSON array. The code attached is one of the last of several variations of what I have tried. I do not understand why I am struggling but really having issues understanding. I have seen and read several examples but can not find the answer I am looking for.

Can someone please help guide me?

Dim j As JObject = JObject.Parse(jsonString)

For Each item As JProperty In nodelist2(0).Item("Values")
   Debug.Print(item.Value)
Next
{[Values, {[
  [
    {
      "Axis": "1",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Acceleration",
      "FileID": 1326,
      "Unit": 0,
      "Value": 0.0547971
    },
    {
      "Axis": "2",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Acceleration",
      "FileID": 1326,
      "Unit": 0,
      "Value": 0.0253521
    },
    {
      "Axis": "3",
      "Channel": -1,
      "Date": "2022/10/20 12:45:48",
      "DescUnit": "Acceleration",
      "FileID": 1326,
      "Unit": 0,
      "Value": 0.0194674
    }
  ],
  [
    {
      "Axis": "1",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Velocity",
      "FileID": 1326,
      "Unit": 2,
      "Value": 1.07888
    },
    {
      "Axis": "2",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Velocity",
      "FileID": 1326,
      "Unit": 2,
      "Value": 0.275461
    },
    {
      "Axis": "3",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Velocity",
      "FileID": 1326,
      "Unit": 2,
      "Value": 0.196169
    },
  ],
  [
    {
      "Axis": "1",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Acceleration Envelope",
      "FileID": 1326,
      "Unit": 6,
      "Value": 0.0292101
    },
    {
      "Axis": "2",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Acceleration Envelope",
      "FileID": 1326,
      "Unit": 6,
      "Value": 0.0187995
    },
    {
      "Axis": "3",
      "Channel": -1,
      "Date": "2022/10/20 00:09:47",
      "DescUnit": "Acceleration Envelope",
      "FileID": 1326,
      "Unit": 6,
      "Value": 0.0122969
    },
 ]
]}]}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The JSON you provided is wrong, below is a correct version of it.
For this, you have a JSON object with element Values that is a JSON array of JSON arrays.

Hope this helps 🙂

{
   "Values":[
      [
         {
            "Axis":"1",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Acceleration",
            "FileID":1326,
            "Unit":0,
            "Value":0.0547971
         },
         {
            "Axis":"2",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Acceleration",
            "FileID":1326,
            "Unit":0,
            "Value":0.0253521
         },
         {
            "Axis":"3",
            "Channel":-1,
            "Date":"2022/10/20 12:45:48",
            "DescUnit":"Acceleration",
            "FileID":1326,
            "Unit":0,
            "Value":0.0194674
         }
      ],
      [
         {
            "Axis":"1",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Velocity",
            "FileID":1326,
            "Unit":2,
            "Value":1.07888
         },
         {
            "Axis":"2",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Velocity",
            "FileID":1326,
            "Unit":2,
            "Value":0.275461
         },
         {
            "Axis":"3",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Velocity",
            "FileID":1326,
            "Unit":2,
            "Value":0.196169
         }
      ],
      [
         {
            "Axis":"1",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Acceleration Envelope",
            "FileID":1326,
            "Unit":6,
            "Value":0.0292101
         },
         {
            "Axis":"2",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Acceleration Envelope",
            "FileID":1326,
            "Unit":6,
            "Value":0.0187995
         },
         {
            "Axis":"3",
            "Channel":-1,
            "Date":"2022/10/20 00:09:47",
            "DescUnit":"Acceleration Envelope",
            "FileID":1326,
            "Unit":6,
            "Value":0.0122969
         }
      ]
   ]
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading