Forum Discussion
Can you give a concrete example, that might help to clarify things.
Here’s a few ways to delete fields in a document:
- In the Mapper, if you leave the “Target Path” property for a row empty it will treat the expression as a JSON-Path and delete whatever fields are on the path.
- Through the expression language, the Object.filter() method will return a new object with only the fields that match the callback passed into the method. So, in a Mapper, you can write an expression like
$.filter((val, key) => key != 'foo')
to create a new document and then set the target path to ‘$’ to write out the new object.
I know I can do that manually. That is great if you never want the field and know which portions you don’t want. Neither is the case for me.
If I have:
"Address": [{
"value": {
"AddressType": {
"value": "Mailing"
},
"AddressLine1": {
"value": "3740 Turtle ST"
},
"City": {
"value": "DALLAS"
},
"StateProvince": {
"value": "TX"
},
"Zip": {
"value": "75215"
},
"Country": {
"value": "US"
}
}
}, {
"value": {
"AddressType": {},
"AddressLine1": {},
"City": {},
"StateProvince": {},
"Zip": {},
"Country": {}
}
}]
I want it to be changed to:
“Address”: [{
“value”: {
“AddressType”: {
“value”: “Mailing”
},
“AddressLine1”: {
“value”: “3740 Turtle ST”
},
“City”: {
“value”: “DALLAS”
},
“StateProvince”: {
“value”: “TX”
},
“Zip”: {
“value”: “75215”
},
“Country”: {
“value”: “US”
}
}
}
}]
Of course, there are other parts that may or may not be null. I want any null part to be ignored.
Do you have any ideas how to use such functionality for a general case such as this? The models may change, and there are several.
Steve