JSON Writer

Hello everyone!

Using the JSON Writer component -

I have added a collection called “SourceCheck”. Is there a way to make this collection tag completely disappear when the “attType” tag (in the parent element) = “qwerty”, but appear when the “attType” tag (in the parent element) != “qwerty” . Note: currently the array is empty when there is no data to bind, but can the tag disappear accroding to the “attType”.

Example of the JSON pasted below. Thank you.

{
“Status” : “CONFIRMED”,
“source” : {
“Code” : “ABC”,
“Id” : “12345678910”,
“coexistence” : [ {
“Code” : “BCD”,
“Id” : “12345678”
} ]
},
“id” : {
“idStatus” : “CONFIRMED”,
“verification” : null,
“att” : [ {
“attType” : “qwerty”,
“attStatus” : null,
“doc” : [ {
“documentName” : “eCard”,
“eID” : “AUS2022”
} ],
“SourceCheck” :
} ]
}
}

Hello Aadharsh,

Unfortunately, it is currently not possible to omit the “SourceCheck” array easily given the way how CloverDX is currently designed to work. There is already an improvement suggestion ticket logged in our JIRA but it hasn’t made its way to the software yet. If it was a single value element (as opposed to an array), you could take advantage of the “Writer null value” property and set it to false. However, if you really need to remove the entire array completely you would have to arrange some sort of a workaround solution.

One of the possible workaround options would be to write the JSON data as you normally would including the unwanted empty array field but instead of outputting directly to a file you would write data to an output edge. JSONWriter File URL would be:

port:$0.myJsonOutput:discrete

Then, you would go on to use the Map component and remove the “SourceCheck” array by using the replace() CTL function. For instance:

$out.0.myJsonOutput = replace($in.0.myJsonOutput , ‘“SourceCheck”:,’, “”);

Lastly, you would simply write to modified JSON data by using FlatFileWriter into a file.

Best regards.