How to make JSON Attributes optional in export mapping?

I have a JSON Structure like this Lines:[  {"LineNumber": "1",       "LineType": "Item",       "Quantity": "1",       "UnitPrice": "10.00",       "LineAmount": "10.00"        },        {        "LineNumber": "2",        "LineType": "Freight",        "LineAmount": "2.30"        } ] Mendix Generates the out put like this. Lines":[{"LineNumber":1,"LineType":"Item","Quantity":1,"UnitPrice":10,"LineAmount":10},{"LineNumber":2,"LineType":"Freight","Quantity":0,"UnitPrice":0,"LineAmount":2.3}]}   As you can see Quantity and UnitPrice are not needed for my Linenumber 2. How do configure my export mapping so that only fields that were declared/set in the Entity object are actually generated in output JSON.      
1 answers

Hi Bhanu,

Mendix will export the object as defined in the Export mapping. If the value is empty, it will be omitted, like you want. I see 2 possible solutions to get those 2 attributes empty:

  1. Change the value of the attribute to empty before you do the export mapping
  2. Change the import mapping using a microflow value mapping, checking if Quantity = 1 then return empty


Good luck!

Kind regards,