10 Replies Latest reply on Aug 3, 2018 8:02 AM by vamshi itukala
      • 1. Re: Convert XML output to JSON output in ICRT Process
        bhim mantha Guru

        Hi ,

         

        Can u provide some screenshots of your process design ?

         

        The format of O/P you want from the process is dictated by Content-Type header you set .

         

        -Bhim

        • 2. Re: Convert XML output to JSON output in ICRT Process
          vamshi itukala Seasoned Veteran

          Service Connector Header image:

           

          My Outputs Image: I am looking JSon format for payload Output field

           

          My Test results :

           

          • 3. Re: Convert XML output to JSON output in ICRT Process
            bhim mantha Guru

            Your Service Connector is always going to return the XML unless you capture the raw JSON .

             

            Is your requirement to return a JSON as the output of process.

             

            Would you please provide what your service is returning and your iteration logic and what you want as teh final output of the process ?

             

            -Bhim

            • 4. Re: Convert XML output to JSON output in ICRT Process
              vamshi itukala Seasoned Veteran

              Yes, my requirement is to return json.

               

              My iteration logic: for Example, I do have 10 codes as input. I need to pass each code as parameter to URI and get the data related to that code in json. This way I need to repeat the process for each code and append the data to same JSON output file.

               

              I need output in json file instead of xml.

               

              Thanks

              • 5. Re: Convert XML output to JSON output in ICRT Process
                bhim mantha Guru

                Ok , can you provide a sample of what data is being returned for each code ?

                 

                 

                -Bhim

                • 6. Re: Convert XML output to JSON output in ICRT Process
                  vamshi itukala Seasoned Veteran

                      {

                          "tenantId": "xyz",

                          "type": "abc",

                          "code": "ab",

                          "enabled": true,

                          "sourceMappings": [

                              {

                                  "source": "source1",

                                  "values": [

                                      {

                                          "code": "ab",

                                          "value": "abc",

                                          "enabled": true,

                                          "canonicalValue": true,

                                          "downStreamDefaultValue": true

                                      }

                                  ]

                              },

                              {

                                  "source": "qwe",

                                  "values": [

                                      {

                                          "code": "ab",

                                          "value": "abc",

                                          "enabled": true,

                                          "canonicalValue": false,

                                          "downStreamDefaultValue": true

                                      }

                                  ]

                              }

                          ],

                          "attributes": [

                              {

                                  "name": "LASTUPDATEDBY",

                                  "value": "name"

                              },

                              {

                                  "name": "LASTUPDATEDDATE",

                                  "value": "datetime"

                              }

                          ],

                          "startDate": 1477753311110,

                          "endDate": 0,

                          "updatedBy": "username",

                          "updateDate": 1525378970532,

                          "version": 1

                      }

                  • 7. Re: Convert XML output to JSON output in ICRT Process
                    bhim mantha Guru

                    Thanks.You can use the concept of process objects and then use a list pattern where in you hold the response for each iteration and finally at the end return the populated list .

                     

                    If you set the content-type of your request as JSON when you invoke the process, it will automatically return as JSON.

                     

                    Ignore the Service connector XML response that's generated , that just makes it easy to work with data inside the process and generate process objects .

                     

                    Please look at the list functions mentioned below.

                     

                    List Function Examples

                    Perhaps the most common example of using the liste functions is to get an object from a list each time a step is invoked, possibly from within a repeated Process or Service step. For example:

                    LET mylist.Current:=list:head(mylist.List)
                    LET mylist.List:=list:tail(mylist.List)

                    The following example converts an object list in a semicolon-separated list, then iterates over each item:

                    for $objectid in list:sequence($objectlist)
                    ...

                    The following example converts a sequence of IDs into a semicolon-separated list of IDs for an object list for hosted objects. For an object list for process objects, it returns a sequence of values:

                    let $mergedObjectLists :=
                       ( as:sequence($objectlist1), as:sequence($objectlist2) )
                    return list:list($mergedObjectLists)

                    • 8. Re: Convert XML output to JSON output in ICRT Process
                      vamshi itukala Seasoned Veteran

                      Thanks Bhim.

                       

                      In my process, I put in below way

                       

                      But I am receiving empty braces  { } for every iteration.

                       

                      and If you dont mind can you please tell the above process in detail or in steps based on my sample json . I am not getting it exactly.

                      • 9. Re: Convert XML output to JSON output in ICRT Process
                        bhim mantha Guru

                        Sorry , I didn't realize that you were writing it to a file .

                         

                        If it's just dumping the JSON that you get from API as is to a file . This is what you can do .

                         

                        Create an output variable in service connector of type text .

                         

                        Use expression and then write this Xquery

                         

                        {$RestResponse/*:payload/text()} . This will return the raw JSON.

                         

                        In the file writer , pass this payload as a text . So use ContentFormat as text

                         

                        Hope this helps.

                        1 of 1 people found this helpful
                        • 10. Re: Convert XML output to JSON output in ICRT Process
                          vamshi itukala Seasoned Veteran

                          Thanks for your patience and help Bhim.

                           

                          I guess its working. i am able to see output in json format in service connector. let me try this in process and will let you know.

                           

                          One more thing,

                           

                          Since I append all input codes json response to one file, I need each response to be separated by comma(,). How can I achieve this.

                           

                          Thanks