Hi,
I am transforming XML to JSON using WTX 8.4.1.4, wherein in the WTX map I am trying to handle the new line coming as a part of a field value from input xml. To generate a valid json, replacing the new line character (<NL>) with space(<SP>), using SUBSTITUTE function. But, when the map is deployed in DataPower, it generates an invalid json.
How can we handle new lines in xml, when transforming into json?
Mentioned below are expected input and output when deployed in DataPower:
Expected input:
<message>
<comments>text
not
here</comments>
</message>
Expected Output:
{"comments":"text not here"}
Mentioned below are current input and output when deployed in DataPower:
Current Input:
<message>
<comments>text
not
here</comments>
</message>
Current Output:
{"comments":"text
not
here"}
Error logged in DataPower:
Invalid JSON document at line 1. Partial content:'{"comments":"text' near #17 character
Logic used:
=SUBSTITUTE(comments Comp:ElemDecl message Element:InputXMLCard ,"<NL>","<SP>" )
Attached the project for reference.
Thanks in advance :)
------------------------------
Pranjal Deshmukh
------------------------------
#B2BIntegration#SupplyChain