1 2 Previous Next 18 Replies Latest reply on Aug 8, 2018 10:19 PM by bhim mantha

    How to append json object into exisiting json array in ICRT process

    vamshi itukala Seasoned Veteran

      Hi,

      I do have Json file as shown below, I need to insert the data of source3 into sourceMappings in my json.

      {

              "tenantId": "xyz",

              "type": "abc",

              "code": "ab",

              "enabled": true,

              "sourceMappings": [

                  {

                      "source": "source1",

                      "values": [

                          {

                              "code": "ab",

                              "value": "abc",

                              "enabled": true,

                              "canonicalValue": true,

                              "downStreamDefaultValue": true

                          }

                      ]

                  },

                  {

                      "source": "source2",

                      "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

          }

       

      I need to add below object to JSon array, for this my input is csv file with data, convert to json object and then insert into json array.

       

      step1:CSV file

      Input: code, value, enabled, canonicalvalue, downstreamdefaultvalue

       

      step2: COnvert to json object

       

      {

                      "source": "source3",

                      "values": [

                          {

                              "code": "ab",

                              "value": "abc",

                              "enabled": true,

                              "canonicalValue": false,

                              "downStreamDefaultValue": true

                          }

       

      step 3:

       

      Insert this above json object into my main json sourcemappings array as source3.

       

      Please help me on this.

       

      Thanks

        1 2 Previous Next