JSON Import mapping

0
Hi,   I have an JSON object with few boolean values. I have created the Import mapping using the JSON structure. When i try to get the REST response i m getting Null for few boolean fields , since the import mapping has created all boolean fields not String. I m getting exception during mapping (Null cant be mapped to Boolean) . This can be solved if it chnage the boolean fields to String. But is ther any other way, whereh i can make the Import mapping to accept null values?
asked
2 answers
1

mendix boolean can only be true or false. create a microflow which sets the null values to false?

answered
0

Indeed a Boolean value can only be ‘true’ or ‘false’, so normally a ‘null’ value means a definition fault. There are a few solutions:

1) If the Boolean value is a result of your own programming then you can change the attribute ‘Default value’ setting to your fail safe value ‘true’ or ‘false’ in your domain model.

2) If you import the JSON value from an external source, then you can:

a) Ask the supplier of the data of he can fix the situation,

b) If that is not possible you can use a microflow to test if the JSON data contains an other value then ’true’ or ‘false’. If so you must replace that ‘Null’ value to your fail safe Boolean value. The microflow has to calculate the offset to the position of the ‘null’ Boolean value, merge your fail safe default Boolean value before the mapping take place. To make this approach a success, dependence on the kind of characters (are there always single or double quotes) around the Boolean ‘null’ value.  You can also remove the malformed Boolean value and let your domain model merged the fail safe Boolean value.

answered