Ability to remove map fields which are empty
Opened this issue · 4 comments
Have a flag on the transform to remove empty fields.
One could have a map with 2 fields
F1->Mapped to DataField DF1
F2->Mapped to Data Field DF2
If the data doesn't have DF2, there should be a provision on the transform to say remove this field
So the output when there is no DF2 field should only be F1->DF1 and the empty F2 which did not receive a value from DF2 should be removed.
Use this (recently added and not yet documented) syntax:
"abc": "{<code>}"
This means: replace with the value in the code property of the data source object if it exists. If the code property doesn't exist in the data source object, remove the abc property from the result object
Another trick is within a function transform, return this to delete the result object:
"<!delete>"
"abc": "{<code>}"
.
This feature did what was required.
Documenting for a better view
Instead of
"phone": "{{phone}}"
.
This would create an empty phone node if the phone is null or not found in the original document to transform.
Do
"phone": "{<phone>}"
This needs to have another enhancement.
what is needed is a hybrid solution.
Lets assume there are two fields in the incoming data
given_name
family_name
The mapping changes given_name to firstName and family_name to lastName.
If we do
firstName: "{<given_name>}"
lastName: "{<family_name>}"
If the given_name is empty or null the map won't copy. The issue here is if we do change first_name once with a non null value and then if we want to remove this. The map would not allow the null value to be entered.
So this feature needs to be enhanced to the following
if a field is found in the input then the map should take it. If the field does have a null value then the map should put back the null value.
E.g
"given_name": "Mary"
next we give
"given_name": null
Here the expectation is the mapping should give "firstName": null. Currently it's removing this field as it treats a field with null value and a field not present as same.
if only data has only that field
"family_name": "Jane"
The mapping should only give
"lastName" : "Jane". Here it can removing firstName field correctly.