My original XML looks like this:
<v14:CodigoDelCupoControlado xsi:nil="true" xmlns:v14="http://esb.cla.cl/EnterpriseObjects/Credito/V1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
The output of my XMLtoJSON is like this:
"CodigoDelCupoControlado": { "nil": true, "": "" }
Desired output:
"CodigoDelCupoControlado": ""
By modifying the XML to remove the xsi:nil
attribute, before applying the XMLToJSON policy, I can get the desired result. The JavaScript for this "Temporary solution":
Is there a better solution that does not involve adding a JS policy to remove all nil?
Solved! Go to Solution.
The problem is, as you have found, the attribute on the CodigoDelCupoControlado
element. The XMLToJSON policy will try to do the right thing.
There is no way to tell the XMLToJSON policy to simply "ignore" the attributes on every element. That seems like a possibly interesting feature, but I've never heard of anyone asking for that.
So the "temporary solution" you've developed, is a good way to handle this situation.
If you don't like that, there are some alternatives I can think of:
None of these are particularly "better" than what you have already found.
The problem is, as you have found, the attribute on the CodigoDelCupoControlado
element. The XMLToJSON policy will try to do the right thing.
There is no way to tell the XMLToJSON policy to simply "ignore" the attributes on every element. That seems like a possibly interesting feature, but I've never heard of anyone asking for that.
So the "temporary solution" you've developed, is a good way to handle this situation.
If you don't like that, there are some alternatives I can think of:
None of these are particularly "better" than what you have already found.