3 Replies Latest reply on Jan 25, 2018 7:41 AM by Scott Nelson

    Process object question

    Prashanth S Active Member

      Hello,

       

      I have requirement to generate JSON response as below based on some SOAP response.

       

      {

      "Rate":[

                     75.65,

                     60.60

                  ]

      }

       

      To accomplish this requirement, I created a process object named po-Rate with a field named "Rate" of type Object List with reference to "Any". My process has a service call step to make SOAP request and using the response I'm populating the po-Rate process object.

       

      Process is returning JSON response with double quotes.

       

      {

      "Rate":[

                     "75.65",

                     "60.60"

                  ]

      }

       

      We do not want double quotes in the response. How can I accomplish this?

       

      If there was a option to define field "Rate" of type Object List with reference to "Number" datatype, then I think double quotes can be avoided. But ICRT does not have this option. Please let me know if there are any alternate solutions for avoiding double quotes.

       

      Here is the xquery expression I have used to populating the Rate field.

       

      for $temp_rate in $something

            return(

            <Rate>{$temp_rate/Price/text()}</Rate>

            )

       

      And also if I have only one item added to process object list, ICRT is not including "[" in the response.

       

      {

      "Rate": "75.65"

      }

       

       

       

      Thanks,

      Prashanth S

        • 1. Re: Process object question
          Prakash Jain Guru

          HI Prashanth,

           

          Could you try to create a process object with one field(Design home > new > process Object) with data type as integer and create a output variable of type process object and try the same ?

           

           

          Please find the attached screenshots:

           

           

          for second query:

           

          Use the below sample Xquery to let ICRT know that its of type array and not primitive type:

           

          <root xmlns:m="urn:informatica:ae:xquery:json2xml:meta-data">

          <a m:isArray="true">1</a>

          <b>3</b>

          </root>

           

          Thanks,

          Prakash Jain

          • 2. Re: Process object question
            Prashanth S Active Member

            Hi Prakash, Thank you for the detailed response. This approach is getting rid of double quotes but the JSON response is not in the format expected. We need the JSON output as below:

            {

               "Rate":[

                  1,

                  2,

                  3,

                  4

               ]

            }

             

            For the array issue, can we assign xquery (with root xmlns) output to a process object field? I think we cannot. For xquery approach, we should have the output field type defined as a text and use util:toJSON() for converting the xquery output to JSON. Please let me know if my understanding is not correct or if I'm missing anything.

            • 3. Re: Process object question
              Scott Nelson Guru

              Have you tried making your output field an Array of Any and inserting your process object into that field? I would expect it to output an array.

               

              Another, cruder approach would be to return a text value that is actually your JSON. You could follow the steps in https://kb.informatica.com/howto/6/Pages/18/496298.aspx  and replace the CSV input with your object.

               

              I actually did what you are trying to do once, but can't find the process at this time. If I find it later I will update this response with the example.