AnsweredAssumed Answered

Is there a way to prevent NULL entries from being mapped to a JSON array?

Question asked by george.swartzendruber826995 on Apr 11, 2018
Latest reply on Apr 19, 2018 by george.swartzendruber826995

I have a process that is mapping from XML to JSON. In the corresponding map, I have a repeating XML node that I want to map over to a JSON array (originally more complex, but I narrowed it down to this and am still seeing the issue). What I would expect to happen is that when the XML node contains a null value (is empty) it doesn't create an entry in the JSON array (similar to how a null XML node won't create the JSON attribute in non-repeating instances). However, if at least one of the repeating XML nodes has a value, then all of the XML nodes get mapped over to the JSON array, and those without values land as a null.

 

Input XML:

<TestXML>

   <RepeatingNode/>

   <RepeatingNode/>

   <RepeatingNode/>

   <RepeatingNode>Some Value</RepeatingNode>

   <RepeatingNode/>

</TextXML>

 

Expected Output JSON:

{

   "jsonArray": [

      {

         "arrayValue": "Some Value"

      }

   ]

}

 

Actual Output JSON:

{

   "jsonArray": [

      null,

      null,

      null,

      {

         "arrayValue": "Some Value"

      },

      null

   ]

}

 

I'm currently just removing the nulls via a Data Process shape, but this feels like something that should just work. Any thoughts?

Outcomes