[WM20] - How to prse JSON and extract info from it?

Startbeitrag von Yogi Yang am 10.04.2017 16:33

Hello,

I am try to extract information from JSON string which comes something like this:

[{"name":"titlepages\/maha_5rbixott.png","usrName":"maha.png","size":38916,"type":"image\/png","thumbnail":"titlepages\/thmaha_hm2iir2t.png","thumbnail_type":"image\/png","thumbnail_size":38916,"searchStr":"maha.png,!:sStrEnd"}]

I want to extract the name of image which in this case is - maha_5rbixott.png

TIA

Antworten:

Hi

sResult is string=extractstring(JsonString,"titlepages\/",2)
sResult=extractstring(sResult, charact(34),1)
info(sresult)

should do the trick

Best regards

von Fabrice Harari - am 10.04.2017 19:03
Thanks Fabrice,

Here is the code I used to Extract String:

sBookCoverImageFileName = ExtractString(sBookCoverImageFileName,2, Charact(34) + "titlepages\/",FromBeginning)
sBookCoverImageFileName = ExtractString(sBookCoverImageFileName,1, Charact(34) + "," + Charact(34),FromBeginning)


It does the same thing as you have suggested in your snippet.

Once again thanks for your help.

Regards,

von Yogi Yang - am 11.04.2017 05:06
I find it easier just to turn it into a variant and deal with that...

ie
json is string = VariantToJSON(some_json_string)

someField = json.TitlePage

(or better practice would be
IF json.TitlePage..EXIST then someField = json.TitlePage
)


von ChristoK! - am 11.04.2017 05:54
Quote
ChristoK!
I find it easier just to turn it into a variant and deal with that...

ie
json is string = VariantToJSON(some_json_string)

someField = json.TitlePage

(or better practice would be
IF json.TitlePage..EXIST then someField = json.TitlePage
)

This is not possible in case of WM..

Regards,

von Yogi Yang - am 11.04.2017 13:28
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.