PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Best way to deal with JSON payloads.
Best way to deal with JSON payloads.
Iniciado por guest, 23,ago. 2017 21:25 - 1 respuesta
Publicado el 23,agosto 2017 - 21:25
Hello All:

I have to call a REST web service which returns data in JSON format, and I have to look for some fields and display them in the web page.

I tried JSONExecute( ) but I got "send error"... I tried with RESTSend() and it worked fine.
Now, my question is; what is the best way to deal with the JSON payload? Should I convert it to Variant or a structure? Should I use Deserialization?

Thanks for sharing your experiences.

Regards;
Gus
Publicado el 24,agosto 2017 - 00:51
I don't have enough experience with JSON in WinDev to know the best way, but this is how I do it. I use a variant. Below is a simple implementation.
sJson is string = // your JSON payload vJson is variant = JSONToVariant(sJson) // Loop through each root object FOR i = 1 _TO_ vJson..Occurrence Trace(vJson.Field1) END