Json to XML - "&" changing to "&"- apigee opdk 4.50

Hi

we are using opdk 4.50 .

We are having issues with json to xml policy.

below is a sample json payload(which is url encoded)

 

{            
"id":"abcd1234"
}

 

The payload is tranformed to xml using  json to xml policy 

After parsing using json to xml, the output is becoming below:

 

<id>&amp;#x61;&amp;#x62;&amp;#x63;&amp;#x64;&amp;#x31;&amp;#x32;&amp;#x33;&amp;#x34;<id>

 

Any idea how to fix this?

Regards

Solved Solved
0 3 889
1 ACCEPTED SOLUTION

That transformation is not broken.  Nothing to fix! 

The ampersands need to be encoded that way in XML. 

The backend system will receive an ampersand, if it handles XML properly. 

If you are asking if you can persuade the JSON-to-XML transformation in Apigee to NOT encode the ampersands, the answer is NO, you cannot persuade Apigee to produce not-well-formed XML, at least not with the JSON-to-XML policy. 

 

 

View solution in original post

3 REPLIES 3

I understand the point .

However our backend target system accepts "&" in the payload 🙂 

Is there a way to fix this transformation in apigee?

That transformation is not broken.  Nothing to fix! 

The ampersands need to be encoded that way in XML. 

The backend system will receive an ampersand, if it handles XML properly. 

If you are asking if you can persuade the JSON-to-XML transformation in Apigee to NOT encode the ampersands, the answer is NO, you cannot persuade Apigee to produce not-well-formed XML, at least not with the JSON-to-XML policy.