Http Request Parsing VVVV Gamma

Hello there,

I am very new at VVVV and I am having a very hard time to properly parse the response of an http request. I know that the response format is json, but the string receive behaves somewhat unexpected and i am unable to get anything out of if.
Please have a look at screenshot below (i would have posted the patch too, but the system thinks that I am too young to do so. I feel flattered by this flirtatious system admin, but it does not really help my case. anyway… so I have to do without)

I would be very happy if one could help me out. Thank you very much in advance.

Hey there, and welcome :)

To parse JSON, have a look at the ParseJSON node. It’ll return an XElement you can then parse with the XElement nodes. See the screenshot below (and attached patch) :

SimpleJsonParsing.vl (9.5 KB)

Now about those non-printable characters instead of new lines… Not sure why they show up like that! A stab in the dark: does ParseJSON work anyway?

1 Like

oh, thank you so much for the response!

But - Unfortunately - i get an error message and i have no idea what it means. have a look here:

The help patch does not show this error, but it turns red as soon as i drop it into my file. How can that be? Would you mind to help me out and tell me what i am doing wrong? thanks a lot!

Looks like your JSON string starts with an array, but ParseJSON wants something that starts with an object.

I would simply use some string concatenation to “wrap” your JSON string with an object before plugging it to ParseJSON (using the “+” node). Looks a bit dirty, but that should work :)

hi - hope you had nice xtmas and relaxing days!
I had a go at the above, but -unfortunately- with very little success.

The file seems to be a valid json code, webpages like “online json viewer” or others don’t have a problem with it. Adding parenthesis makes it invalid. I have copied it in for ease of reference:

[
  {
"id": "id000cbb71-fa8d-4d25-8989-96c0285d5c9a",
"deviceSerial": "IU885/004",
"channelIdentifier": "ch11",
"name": "1100ML Algae Stirred 8-16",
"interval": 1,
"value": null,
"multiplier": 1
  },
  {
"id": "id84644194-3c6a-4a0a-8625-9dd891c88c9d",
"deviceSerial": "IU885/004",
"channelIdentifier": "ch5",
"name": "Moss",
"interval": 1,
"value": null,
"multiplier": 1
  },
  {
"id": "id2adcd223-185c-47e7-859c-c85d305cc068",
"deviceSerial": "IU885/004",
"channelIdentifier": "ch7",
"name": "300ML Chlorella Gel",
"interval": 1,
"value": null,
"multiplier": 1
  },
  {
"id": "id6aec6eed-6cbe-4cfa-831e-cb9599d06dd4",
"deviceSerial": "IU885/004",
"channelIdentifier": "ch9",
"name": "1100ML Algae Do + Spectro ",
"interval": 1,
"value": null,
"multiplier": 1
  }
]

This makes me wonder whether the node actually works in vvvv gamma? To me it seems that vvvv beta is a little bit more forgiving:

Indeed it isn’t but try this:

Note the brackets are curly

thanks for your answer! and -uuuppppps, i meant curly brackets. my mistake!

… butttttt…

… i am still puzzled: the patch above does not work in my case. It turns a correct JSON code into something that can not be parsed.

Please have a look here:

and here is the result of the concatenated string:

Yeah its an annoying detail that I’ve come across in the past.
Even though the text you included isn’t working for me the output from your HttpResult should be correctly formatted for the trick to work correctly (note: you shouldn’t need to add any extra spacing between the the additional curlies for this to work).
If not I think we’ll need the devs’ input or find an alternative json parser.

The array (object) has to have a name.

DeserializeJson.vl (16.8 KB)

3 Likes

Wow! It works! That’s super cool, I would never have made it! Thanks a lot!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.