5 Replies Latest reply on Nov 8, 2019 12:48 AM by Shambhavi GN

    ICRT util:toJSON

    Amiel Dimaculangan New Member

      Hi all,

      We are trying to convert xml to JSON structure. We follow this documentation https://kb.informatica.com/howto/6/Pages/19/502991.aspx. Is there any way that we can remove the root xml element when we convert it to JSON?

       

      example:

       

      Actual Output:

      {

      "SyncRequestPO": {

      "requestedMessageType": "XXXXX",

      "timeStamp": "XXXXXXXX",

      "messageType": "XXXXXX",

      "messageId": "XXXXXXX",

      "source": "XXXXXXXX",

      "sendRelatedMessages": false,

      "requestedMessageId": "XXXXXXXXXX",

      "version": 1

      }

      }

       

      Desired Output

       

      {

      "requestedMessageType": "XXXXX",

      "timeStamp": "XXXXXXXX",

      "messageType": "XXXXXX",

      "messageId": "XXXXXXX",

      "source": "XXXXXXXX",

      "sendRelatedMessages": false,

      "requestedMessageId": "XXXXXXXXXX",

      "version": 1

      }

        • 1. Re: ICRT util:toJSON
          bhim mantha Guru

          Hi ,

           

          Either you can use Output is a whole payload for the output of your process or it's an api call you are making in the binding section you have JSON unwrapped.

           

          -Bhim

          • 2. Re: ICRT util:toJSON
            Prakash Jain Guru

            Hi Amiel,

             

            Please let us know if you have any further questions in this regard to assist you further ?

             

            Thanks,

            Prakash Jain

            • 3. Re: ICRT util:toJSON
              Amiel Dimaculangan New Member

              Hello,

              Ideally we would like to store the JSON to AWS SQS queue, so in the process we are using a service call to write JSON to the queue. We've tried using Output is a whole payload, but we are still having the same issue.

              Is there any work around that we can do to send the JSON to the SQS queue without the root element?


              Thanks,
              Amiel








              • 4. Re: ICRT util:toJSON
                Mehul Sorathiya Seasoned Veteran

                Hi Amiel -

                 

                To remove root element, I have used below workaround for the same requirement. 

                 

                fn:substring

                (

                fn:substring-after($temp.tmp_json, '{"root":'),

                1,

                fn:string-length(fn:substring-after($temp.tmp_json, '{"root":'))-1

                )

                • 5. Re: ICRT util:toJSON
                  Shambhavi GN New Member

                  Hi Mehul/Prakash,

                   

                  I am passing input from Salesforce to AWS SQS in ICRT process. Need to send data as json to AWS SQS.

                  Can you please let me know how do I need to pass it to AWS SQS webservice ?

                   

                  I am passing below in the expression as message :

                   

                  let $message := (

                  <root>

                  <Status>New</Status>

                  <Name>abc</Name>

                  </root>

                  )

                  return util:toJSON($message/*)

                   

                  But I am getting error as :

                  Error Code : Unexpected Fault

                  Error Reason: Error executing cloud process[hostRuntimeCall] with id [9545]

                   

                  Also please help me how to send column instead of hardcode value in xml expression. I used "{" but it didnt work. Thank You!