Empty attributes in JSON

0
When using JSON export mapping, empty attributes are left out, raising the question how to indicate that a field should be emptied.   Suppose you have an object Person: Age: 55 Street: Broadway Number: 10 Suffix: C   Now the json will look like this: {"Age":55,"Street":"Broadway","Number":10,"Suffix":"C"} Now suppose the person moves to Wall Street 8 and we need to inform others. We will send: {"Age":55,"Street":"Wall Street","Number":8} The suffix is left out, as it's empty now, but the result in the receiving app will be that Person now lives at Wall Street 8C.   So how are we supposed to communicate empty attributes in json? I can think of two options: 1. We could send empty strings instead of empty, but that only works for string and enum fields and also it feels like cheating to send a value that isn't there, although maybe we should avoid discussions about null / empty / undefined / empty string etc and whether they are values or not. 2. We could build the json string manually in a microflow, adding "Suffix":null when needed. This seems inefficient though and error prone.   Maybe I'm missing something. How to proceed in Mendix? In XML you can set nillable true and optional false. How would you synchronize an emptied attribute using json mapping?
asked
2 answers
4

Hi Martin,

In an Export Mapping, you can set ‘Send empty values’ to true in the Properties pane.

answered
0

Depending on your use case you can also decide to always recreate the record if you have it. You wouldn’t have the need to check each attribute that way.

answered