Forum Discussion

shubhisharma's avatar
shubhisharma
New Contributor
8 years ago

Parsing exception

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.

3 Replies

  • dmiller's avatar
    dmiller
    Former Employee

    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.

    • shubhisharma's avatar
      shubhisharma
      New Contributor

      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].

      • tstack's avatar
        tstack
        Former Employee

        FYI, the sl.ensureArray() function will do the same as the code you posted, but is a little shorter and easier to remember.