Json null

  

I have a list of integer that is populated using Rest that consume external web service. So this part of json respond:

[2,null, null,4]

Is deserialazed by Ouatsystems Rest to the list integer. The poblem is that when i assigned that null value to an int, it raised java exception error.

Myquestion is is that json valid? Is that list valid? How to detect that it is a null?

Thank you

The json is valid as i read a book on json. Null means "no value" in json, not undefined as in javascript.

But what is amaIzng is that when i debug in outsystems...it is known in the debug watch as -undefined-..

Hi!

Typically, when JSON is used into the REST, do not use null instead use empty.

JSON is agnostic to data typing, the emitters and receivers are responsible for understanding and treating typing, only the structure of the message is important.


OS does not convert an array into a list in REST Response, you need do that using the JSON2RecordList of ArdoJSON.

See this exemple:

https://www.outsystems.com/forge/component/2571/pushwoosh/

Pushwoosh_IS > Logic > Message > MessageGet


additionally, you can replace the null with 0.


Regards,

I do not see json in the link

Here is the sequence;

1. I create a Rest that consume an external web service.

2. When i invoke that Rest, ousystem would deserialize that respon into int list structure.. so i do not think to need jsontorecordlist because it has been deserialized.

3. Now i loop that list that contains elements: 2, null, null, 100

4. When i assign the null to an int variable, a jav.lang.null eception is raised.