on 2023 Feb 09 9:59 PM
Hi experts,
I have an issue in CPI using the JSON to XML converter, I tried to use it and CPI response me the next message: com.sap.it.xmljson.JsonXmlException: Cannot transform JSON document to XML: JSON document does not start with '{'.
I have the following JSON body that I need to convert to XML
I know the problem is [ at the beginning of the body. My question is, how can I remove that symbol to be able to use the JSON to XML converter?
I appreciate your answers
greetings
Request clarification before answering.
Hello Sara,
this is a limitation from the Json to XML Converter as stated in the documentation.
You can simply add a content modifier as described their and process the message.
Here an example with a simulation. I also had to add a second "root" element as their is alos a limitation that the root Object can only have one member. So I added a second root (the name can be adjusted in the Converter).
Content Modifier:
JSON to XML Converter:
Simulation Body input:
Simulation Body Middle:
Simulation Body End:
I hope this helps you with your issue.
Best Regards
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rian,
another simple solution without adding an additional root tag to the payload is to insert a script step which removes the first an the last String
def inputJson = message.getBody(String)
def outputJson = inputJson.substring(1, inputJson.length()-1)
message.setBody(outputJson)
return message
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ryan, this is the beginning of the message, this is the json that the server responds. I want to know how I can delete that symbol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
59 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.