12-02-2020 10:56 AM
Can you help me to remove empty/null value fields from a JSON structure? Kindly suggest pipeline design suggestion or expression language for the below expected results. Thanks!
Input:
{
“INVOICE”: {
“TITLE”: “Test”,
“DESCRIPTION”: “Test124”,
“VERSION”: “”,
“IRN”: “”,
“TRANDTLS”: {
“TAXSCH”: “”,
“SUPTYP”: “B2B”,
“REGREV”: “”,
“IGSTONINTRA”: “N”
},
“NOTES”: {
“ID”: “”,
“TEXT”: “”
}
}
}
Expected Output
{
“INVOICE”: {
“TITLE”: “Test”,
“DESCRIPTION”: “Test124”,
“TRANDTLS”: {
“SUPTYP”: “B2B”,
“IGSTONINTRA”: “N”
}
}
}
12-03-2020 04:13 AM
Hi Rajesh,
Use JSONPath to remove any keys where the values are empty/null as follows: jsonPath($,“$…[?(value == null) || (value == “”)]”)
In a mapper, put this in the expression field and leave the target field blank. Click on Pass Through.
The response is
Please find the attached pipeline.