Yes, I understand what you’re saying.
The problem you are experiencing is due to how JSON encodes text. What you are seeing is not an error, it’s correct behavior. Perhaps your expectations are not valid.
In JSON newlines and tabs must be encoded in strings as \n and \t. You can read about this on the json site.
The conclusion: if you encode a value that has newlines and tabs, then … that’s what you will get. The receiving app must be smart enough to handle the embedded newlines and tabs. Either decode them, or replace them with the appropriate thing for the app scenario.
Just one more comment though:
I think there is a problem with the handling of the CDATA in the XML payload. In my opinion the CDATA should not be passed through into JSON. Rather, the JSON string should be free of CDATA fields. CDATA markup is an XML thing, and it doesn’t belong in JSON at all.
In other words, the payload I would expect, would be something like this:
{
"response": {
"status": {
"responseCode": "00000"
},
"responseDetails": {
"identifier": "1234567",
"contentText": "<POLICY><TITLE>Ploicies></TITLE><OVERVIEW><p>The policy is in place to encourage</p>\n\n<ul>\n\t<li>Preferred</li>\n\t</ul>\n</OVERVIEW><TITLE></POLICY>"
}
}
}
I don’t know what the input XML looks like, I’m assuming.
Let me test this, and if the behavior is as I suspect, I will raise a bug.
But still you will need to deal with the encoded newlines and tabs in the JSON, on the consumer app.
EDIT #2.
ok I just tested this and the behavior I had suspected was occurring, based on your report, is not actually occurring for me. When I send an XML doc with a CDATA section into an XMLToJSON policy, I get JSON that does not include the CDATA.
$ curl -i [https://org-test.apigee.net/echo-xmltojson](https://org-test.apigee.net/echo-xmltojson) -H content-type:text/xml -d '<root><![CDATA[foo]]></root>'
HTTP/1.1 200 OK
Date: Thu, 04 May 2017 19:20:42 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 20
Server: Apigee Router
{
"root": "foo"
}
This is different than the payload you are reporting. I don’t know why that would be. If you want to investigate that, please open a new question and post your source XML.