Hello,
I am currently working on building certain JSON messages.
For doing this I am starting with an XML message that has the desired structure and place the data into this XML. Then I use the JSON Connector to convert my XML into the JSON format.
So far so good.
Due to the fact that sometimes the data of a node does not exist, I would like to know, if there is an option in the JSON Connector that will automatically remove all nodes that are empty in the underlying XML.
For example the following XML Structure shows that some fields have values and other do not:<?xml version="1.0" encoding="UTF-8"?>
<Items xmlns:json="http://arc.cdata.com/ns/jsonconnector" json:array="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Item>
<field1>value1</field1>
<field2>value1</field2>
<field3></field3>
<subnode1>
<subfield1>subvalue1</subfield1>
<subfield2></subfield2>
</subnode1>
<subnode2>
<subfield3></subfield3>
<subfield4></subfield4>
</subnode2>
<field4>value4</field4>
</Item>
</Items>
When sending this through the JSON Connector the result looks like this:n
{
"field1": "value1",
"field2": "value1",
"field3": "",
"subnode1": {
"subfield1": "subvalue1",
"subfield2": ""
},
"subnode2": {
"subfield3": "",
"subfield4": ""
},
"field4": "value4"
}
]
What I want to have would look like this, not including any of the empty fields or substructures:v
{
"field1": "value1",
"field2": "value1",
"subnode1": {
"subfield1": "subvalue1"
},
"field4": "value4"
}
]
I know that I could start adding Conditions to each of the XML Nodes in my XMLMap Connector so that the result would only have the XML nodes that are not empty.
But when it comes to large structures with many fields this is pretty time consuming.
Hence my question is if there is an option in the JSON connector (or any other possibility) to globally remove empty nodes from the JSON.
Thanks for any help or tip.
Gordon