on 2020 Jul 23 1:57 PM
Hello Experts,
I am getting the this error using standard JSON to XML converter: Use JsonReader.setLenient(true) to accept malformed JSON.
I got the payload from HTTP get consuming 3rd party API. With a groovy script I removed already the first "[" and last "]" (as JSON to XML will fail).
Below the payload and the corresponding error message.

this part of the payload:
"Id":"579dc1e6-e983-4543-917c-f524115db14e","CountryCode":"US","Name":"United States"},{"Id":"7b218eb7-219e-46aa-a4fc-694afedb2fe0","CountryCode":"CA","Name":"Canada"},{"Id":"38a20ece-6356-4a56-919f-959a7c94e9b7",
thanks, Markus
Request clarification before answering.
Hi Markus
The JSON to XML Converter step wants a top-level JSON object, not an array (even though a top-level array is valid JSON). So you need to fit your array into an object. This is one way to do it:
{
"objects": [
{
"Id": "579dc1e6-e983-4543-917c-f524115db14e",
"CountryCode": "US",
"Name": "United States"
},
{
"Id": "7b218eb7-219e-46aa-a4fc-694afedb2fe0",
"CountryCode": "CA",
"Name": "Canada"
},
{
"Id": "38a20ece-6356-4a56-919f-959a7c94e9b7"
}
]
}You can accomplish this by adding a Content Modifier step after your API call with the following body expression:
{
"objects": ${body}
}This assumes that your API call returns a JSON array.
Regards,
Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.