01-15-2018 02:46 AM
Hello All,
I am having XML as an input to my pipeline. I have to map the elements from the incoming request and form a new request. I am facing a casting exception stating “Failure: java.lang.String cannot be cast to java.util.Map, Reason: Snap failed unexpectedly and did not provide any reason”.
The catch is incoming XML is not able to recognize array.
Refer the screenshot.
01-16-2018 10:31 AM
If you are certain the incoming XML is an array that’s being treated as an object, then it sounds like a bug that should be submitted through Support.
01-19-2018 09:08 AM
I was somehow able to manage by using an extra mapper in my pipeline. I explicitly converted the object into Array.
I used:
$Object instanceof Array ? $Object : [$Object].
01-19-2018 09:34 AM
FYI, the sl.ensureArray()
function will do the same as the code you posted, but is a little shorter and easier to remember.