JSon, Null element

JSon, Null element

  

How to check that a value returned in a web service in Json structure is a NULL value? I have respond in array like [2,NULL, etc] ant need to identify if it is NULL or not because it will raise an error when inserted NULL to a table.

regards,

When i trace it, it is said 'undefined'. When I use toobject(value)..it is java null exception. How to check if it is null? THank you..

Thank you for the reply..the respond has been in the outsydtem type..it is from Ousystems rest structure. In my case there is an array of integer and some of the elements has NULL values. I want to check if that  value is Null.. how to?

Hi,

In Outsystems the variables don't have NULL values. Every variable is set with the default value depending on the data type of the variable. You can check it here https://success.outsystems.com/Documentation/10/Reference/OutSystems_Language/Data/Data_Types/Available_Data_Types

Regards,

Marcelo

I consume web external service that can be made from non Outsyatems.. 

Hi,

But the response of that external service is saved on outsystems variables. Now we have 2 options or the JSON was mapped into Outsystems variables. or there is a text variable with a JSON inside. In this case you need to deserialize to map it into Outsystems structures/variables. and tha you need to check for default values.

Regards,

Marcelo

Yes..it is saved automatically by Outsyatems when we create rest to consume external service. The return in the outsystems list is aomething like this: [2, null,..]. Is there a function to check if it is null/undefined?

Every time it is assigned to a variable, an exceptoon is raised..and of course we can trick using this behaviour, but it is overkill because i need to loop an array/list...

Iam thinking another way, may be i can trap on after respond callback.. but it is not simple as well..

I will try also tomorrow to create function to check if it is null.. but i am doubr what data type to uae for the null/undefined type.. will it raise exception as well when assigned to the input parameter?

Why there is no function just to check the null that is assugned by outayatems itself in its own atructure for null reapond?

What is a pity .. null is a valid json type.

How come Outsyatems can populate null-undefined-, but has no isundefined function such as other language?

Solution

i trick in on After Respond, i check it now results -999, but i am still wondering.. is it enough to just replace the ResponseText, do i need to change the ResponseBinary as well?:

SyntaxEditor Code Snippet

Replace(CustomizedResponse.ResponseText,"null","""-999""")
Solution