JSON ARRAY

Posted by Giancarlo Alberto Somma on 28-Feb-2020 09:54

Hello to everbody,

quick question.

How I can check if the element, in some case, "customers" is not include in the JSON file?

oJsonArray      = ResultObject:GetJsonArray("customers").

many thanks.

G.

Posted by onnodehaan on 28-Feb-2020 09:56

jsonobject:has("customer")

Posted by Mike Fechner on 28-Feb-2020 10:01

And be aware, that JSON is case-sensitive.

All Replies

Posted by onnodehaan on 28-Feb-2020 09:56

jsonobject:has("customer")

Posted by Mike Fechner on 28-Feb-2020 10:01

And be aware, that JSON is case-sensitive.

Posted by Peter Judge on 28-Feb-2020 13:20

In addition to Has(<property-name>) you should also check for the property's type using the GetType(<property-name>) method. There's also one for arrays.
 
And also also, when dealing with JSON remember that there are far fewer datatypes than in ABL: a JSON string can contain character or date data ; a JSON numeric type can contain integer or decimal data.
 
 

This thread is closed