the JSON standard supports a null value for any type of data.
However, when exporting objects to a JSON message in Mendix, all empty attributes are simply not exported to the resulting JSON message.
The receiving party of this JSON message expects the attribute to be present with a null value, if the attribute value is empty.
Whether or not this is the best solution on their part, it is an accepted value option in the JSON standard.
I'm wondering is anybody else has had this issue, and what their solution was.
The only thing we've currently found as a possible but very ugly solution, is the following:
- Before the export, check whether the attribute is empty.
- If it is empty → Replace value with a dummy value that could never occur if it would be filled
- Export to JSON-string
- String operation Replace on JSON-string where dummy value is replaced with null
If anybody has a better solution, please let me know.
Have you seen the properties of the exportmapping?
I have also used export mapping converter, https://docs.mendix.com/refguide/export-mappings#3-1-entity-mapping-properties.
I am also not aware if there are other ways of doing this.