Converting one JSON format to Another JSON format in outsystem

Converting one JSON format to Another JSON format in outsystem

  

Hello Everyone ,

I'm having a list which contains editable datas and after pressing a button i'm calling an action. I'm serilizing all the datas to get a json format from the list and getting a JSON format as follows. I want to convert this JSON format into another JSON format which further follows.

I have a JSON format that i'm getting is as follows :


[
          {
               "LineItems":  {
                                        "Name":"1234",
                                        "EmployeeID":"22222",
                                        "Address":"dsf",
                                        "Phone Number":"dsf",
                                        "About":"dsf",
                                        "Description":"sadasd"
                                     }
          },
          {
               "LineItems":  {
                                              "Name":"1235",
                                              "EmployeeID":"13",
                                              "Address":"msd",
                                              "Phone Number":"245ds",
                                              "About":"hngh",
                                              "Description":"kjuhijh"
                                    }
           }
]


and I want to convert this to this JSON Format :

{
     "LinesItems":[
                 {
                         "concurExpenseLineId":"12",
                         "expenseName":"dsf",
                         "expenseDescription":"sadasd"

                 },
                  {
                          "concurExpenseLineId":"hngth",
                          "expenseName":"hngh",
                          "expenseDescription":"hghgn"

                   }
       ]
  }

How can I achive this in outsystem ?

Hi Beeta,

As per what I am understanding , your first JSON is a list of type structure of a structure which you want to convert it to convert into a type another structure .Please see the screen shot . 

First define 3 structure as shown in picture namely 'DataOne' , 'ListItems', 'DataNew'. ListItems has one attribute of type DataOne. So here create two list variables of type ListItems and DataNew. Now de-serialized the received data into type first structure 'ListItems 'and it to the first varaible.(Use AppendAll() function ). You will get option to map data while appending it to the variable. then append data from first variable to second variable by using the AppendAll() function and map you respective columns. 


Hello Pranav,

I'm sorry, there was a mistake .

I want to convert in the following Json format :

{
     "LinesItems":[
                 {
                                        "Name":"1234",
                                        "EmployeeID":"22222",
                                        "Address":"dsf",
                                        "Phone Number":"dsf",
                                        "About":"dsf",
                                        "Description":"sadasd"

                 },
                  {
                                              "Name":"1235",
                                              "EmployeeID":"13",
                                              "Address":"msd",
                                              "Phone Number":"245ds",
                                              "About":"hngh",
                                              "Description":"kjuhijh"
                   }
       ]
  }

From List i'm getting JSON as a list of object format and I want to convert it into array of objects format

Beeta Sahoo wrote:

Hello Pranav,

I'm sorry, there was a mistake .

I want to convert in the following Json format :

{
     "LinesItems":[
                 {
                                        "Name":"1234",
                                        "EmployeeID":"22222",
                                        "Address":"dsf",
                                        "Phone Number":"dsf",
                                        "About":"dsf",
                                        "Description":"sadasd"

                 },
                  {
                                              "Name":"1235",
                                              "EmployeeID":"13",
                                              "Address":"msd",
                                              "Phone Number":"245ds",
                                              "About":"hngh",
                                              "Description":"kjuhijh"
                   }
       ]
  }

From List i'm getting JSON as a list of object format and I want to convert it into array of objects format


Ok then in that case you output structure is same as the DataOne [DataNew and DataOne is same]. Here create an output variable of type List of 'DataOne' and then map the columns while appending it . [No need of DataNew structure here]

Hi Beeta Sahoo ,

Were you able to find the solution ?