In XML to JSON Policy - What is best way to convert the following:

Currently JSON is displayed as FROM value below - Want to display TO value...

FROM TO
"ERRDSC": {

"nil": "true",

"": null

},

"ERRDSC": null,
"STSFLG": {

"nil": "true",

"": null

},

"STSFLG": "Y",
0 4 183
4 REPLIES 4

Not applicable

you need not to use XML to json policy here.

You can use a javascript policy to check if it contains ERRDSC or STSFLG. Then you can set conditionally the new payload to the to the one you want.

You can also achieve the same using extract variable policy to first get the ERRDSC or STSFLG. Then use one conditional assign message for the error one and the another assign message for the STS.

Your title says "XML to JSON policy", And thanks for the examples. Looking at your examples, I see no XML. It looks like you're converting from JSON to another shape of JSON. Is that right?

And regarding those examples, Can you extrapolate from those and state in English the difference?

It seems to me that you have two cases, both of them (ERRDSC & STSFLG) have the same JSON payload. And one of them you want to transform to null and the other you want to transform to "Y". Help me understand the difference between the two cases.

Tengo un error parecido, comparto los ejemplos:

XML

<v14:CodigoDelCupoControlado xsi:nil="true" xmlns:v14="http://esb.cla.cl/EnterpriseObjects/Credito/V1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

Respuesta XMLtoJSON

"CodigoDelCupoControlado": {
    "nil": true,
    "": ""
}

Respuesta deseada:

"CodigoDelCupoControlado": ""

It seems like you have a new question.  Please post it, in a new question. 

ask-a-new-question.png