|
| Iniciado por guest, 16,oct. 2015 21:10 - 8 respuestas |
| |
| | | |
|
| |
| Publicado el 16,octubre 2015 - 21:10 |
Hello,
I think a simple question, how can i extract a string what i receive from a webservice in JSON format? By example the received JSON text below, i want the "aantal_cilinders" in a string. By xml format it is very easy with XMLExtractString.
[{"aantal_cilinders":"5","aantal_deuren":"4","aantal_wielen":"4","aantal_zitplaatsen":"5","afstand_hart_koppeling_tot_achterzijde_voertuig":"0","afstand_voorzijde_voertuig_tot_hart_koppeling":"0","
Thanks! |
| |
| |
| | | |
|
| | |
| |
| Publicado el 16,octubre 2015 - 22:56 |
| JSONToVariant and VariantToJSON would be my advice. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 17,octubre 2015 - 08:53 |
| I have tryed this a lot but it stil not works for me. In the Windev help i can`t find some more information. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 17,octubre 2015 - 18:02 |
Or is there a way to convert the JSON data to XML data?
Thanks, Sammy |
| |
| |
| | | |
|
| | |
| |
| Publicado el 17,octubre 2015 - 21:58 |
Hi
Pls see below example:
sJZon is ANSI string =[ {"aantal_cilinders":"5","aantal_deuren":"4","aantal_wielen":"4"} ] jz is Variant jz=JSONToVariant(sJZon) trace("Results:", jz.aantal_cilinders, jz.aantal_wielen)
// Results: 5 4 // ok
HTH
Cheers
Galon |
| |
| |
| | | |
|
| | |
| |
| Publicado el 17,octubre 2015 - 22:05 |
If I were you, I'd do this as below:
sJZon is ANSI string =[ {"aantal_cilinders":"5", "aantal_deuren":"4", "aantal_wielen":"4", "aantal_zitplaatsen":"5", "afstand_hart_koppeling_tot_achterzijde_voertuig":"0", "afstand_voorzijde_voertuig_tot_hart_koppeling":"0" } ] jz is Variant jz=JSONToVariant(sJZon) trace("Results:", jz.aantal_cilinders, jz.aantal_wielen, jz.afstand_voorzijde_voertuig_tot_hart_koppeling)
//output // Results: 5 4 0
Cheers
King |
| |
| |
| | | |
|
| | |
| |
| Publicado el 18,octubre 2015 - 13:00 |
Thanks for the support,
I do as below and receive the error The variant is not an object.
ResStart is boolean
_url is string = "https://opendata.rdw.nl/resource/m9d7-ebf2.json…"
ResStart = HTTPRequest(_url)
sJZon is ANSI string = HTTPGetResult() jz is Variant jz=JSONToVariant(sJZon) Info(jz.aantal_cilinders) |
| |
| |
| | | |
|
| | |
| |
| Publicado el 18,octubre 2015 - 15:10 |
Case closed, pls see as below:
ResStart is boolean _url is string = "https://opendata.rdw.nl/resource/m9d7-ebf2.json…" ResStart = HTTPRequest(_url) sJZon is ANSI string = HTTPGetResult() jz is Variant
sJZon = replace(sJZon,"[", "") sJZon = replace(sJZon,"]", "") sJZon = replace(sJZon,Charact(13), "")
jz=JSONToVariant(sJZon) Info(jz.aantal_cilinders) info(jz.api_gekentekende_voertuigen_brandstof) //trace(jz.api_gekentekende_voertuigen_brandstof)
HTH
Cheers
King |
| |
| |
| | | |
|
| | |
| |
| Publicado el 18,octubre 2015 - 15:41 |
Thanks King!
Works ok for me. |
| |
| |
| | | |
|
| | | | |
| | |
|