PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Reading JSON/Variant nodes
Reading JSON/Variant nodes
Iniciado por guest, 18,abr. 2016 21:03 - 2 respuestas
Publicado el 18,abril 2016 - 21:03
Is there a simple way to make the json node use a variable so we can loop thru the node? or Variant node, might be a more correct reference.

Example:
varResponse.results.id.rewards.bonuses

where id = 19, so we need the node to be:
varResponse.results.19.rewards.bonuses

id is a variable = 19 but this does not translate based on what we see in the debugger.

Screenshot of what the data looks like from debugger:
http://screencast.com/t/nHasKA3m

Screenshot of code :
http://screencast.com/t/aK06vUYr

Thanks for any help on this!
Publicado el 18,abril 2016 - 22:01
Hi,

You should be able to build a string with the names seperated by the dot's like you would access it in the editor itself. Then use indirection { } to access its value (set or get).
A variant is a dynamic variable.

I use this methode to loop through a subset of a piece of XML. The only thing you have to be carefull for is that the name of the variable does not contain a dot.

I think, out the top of my head, code would look like this

id = 19 value is int = {"varResponse.results."+id+".rewards.bonuses"}

Hope this helped !
Danny
Publicado el 18,abril 2016 - 23:36
Danny, this works, I was missing the indirection piece! Thanks!

FOR each r OF {"varResponse.results."+ id +".rewards.bonuses..Member"}