title: combine 2 or more json data in golang
body: <p>I have following two json data :</p>
  <p>First json data :</p>
  <pre class="lang-json prettyprint-override"><code>[
      {
          &quot;id&quot;: 1,
          &quot;availstring&quot;: &quot;PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X&quot;,
          &quot;carrierCode&quot;: &quot;TK&quot;,
          &quot;outboundAirlineCode&quot;: &quot;TK&quot;,
          &quot;image&quot;: &quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,
          &quot;legtraveltime&quot;: &quot;PT14H15M&quot;,
          &quot;totalJourneyTime&quot;: 0,
          &quot;recordSet&quot;: &quot;GDS@PUBLISHED@E@1|UN3FEST|FB00|TK|1||ADT=ADT,CHD=CHD|1,2|LHR|DAC|20220208|20220221|1|||0|||322.000000|771.120000;1|TLXN2XPC|FB05|TK|1|||3,4|DAC|LHR|20220208|20220221|1|||0|||0.000000|0.000000ÞÞGBP1093.12&quot;,
          &quot;lastTicketingDate&quot;: &quot;2022-01-11T23:59:59&quot;,
          &quot;legFareClass&quot;: &quot;Economy&quot;,
          &quot;supportedfunctions&quot;: &quot;None&quot;,
          &quot;requirementValues&quot;: 0,
          &quot;numStops&quot;: 0,
          &quot;departureDate&quot;: &quot;&quot;,
          &quot;origin&quot;: &quot;&quot;,
          &quot;arrivalDate&quot;: &quot;&quot;,
          &quot;destination&quot;: &quot;&quot;,
          &quot;airsegments&quot;: null
      },
      {
          &quot;id&quot;: 2,
          &quot;availstring&quot;: &quot;PUB @1|DAC|TK+723+202202212330+|TK+1979+202202220850+|LHR@@AVL:X|X|X|X&quot;,
          &quot;carrierCode&quot;: &quot;TK&quot;,
          &quot;outboundAirlineCode&quot;: &quot;TK&quot;,
          &quot;image&quot;: &quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,
          &quot;legtraveltime&quot;: &quot;PT16H25M&quot;,
          &quot;totalJourneyTime&quot;: 0,
          &quot;recordSet&quot;: &quot;GDS@PUBLISHED@E@1|UN3FEST|FB00|TK|1||ADT=ADT,CHD=CHD|1,2|LHR|DAC|20220208|20220221|1|||0|||322.000000|771.120000;1|TLXN2XPC|FB05|TK|1|||3,4|DAC|LHR|20220208|20220221|1|||0|||0.000000|0.000000ÞÞGBP1093.12&quot;,
          &quot;lastTicketingDate&quot;: &quot;2022-01-11T23:59:59&quot;,
          &quot;legFareClass&quot;: &quot;Economy&quot;,
          &quot;supportedfunctions&quot;: &quot;None&quot;,
          &quot;requirementValues&quot;: 0,
          &quot;numStops&quot;: 0,
          &quot;departureDate&quot;: &quot;&quot;,
          &quot;origin&quot;: &quot;&quot;,
          &quot;arrivalDate&quot;: &quot;&quot;,
          &quot;destination&quot;: &quot;&quot;,
          &quot;airsegments&quot;: null
      }
  ]
  </code></pre>
  <p>Second json data :</p>
  <pre class="lang-json prettyprint-override"><code>[
      {
          &quot;id&quot;: 1,
          &quot;availstring&quot;: &quot;PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X&quot;,
          &quot;flightType&quot;: &quot;&quot;,
          &quot;ArrivalAirportCode&quot;: &quot;IST&quot;,
          &quot;arrivaldatetime&quot;: &quot;2022-02-09T00:30:00&quot;,
          &quot;ArrivalDate&quot;: &quot;2022-02-09&quot;,
          &quot;ArrivalTime&quot;: &quot;00:30:00&quot;,
          &quot;bookingclass&quot;: &quot;U&quot;,
          &quot;cabinclass&quot;: &quot;Y&quot;,
          &quot;CabinClass&quot;: &quot;Economy&quot;,
          &quot;OperatingAirlineCode&quot;: &quot;TK&quot;,
          &quot;image&quot;: &quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,
          &quot;DepartureAirportCode&quot;: &quot;LHR&quot;,
          &quot;departuredatetime&quot;: &quot;2022-02-08T17:40:00&quot;,
          &quot;DepartureDate&quot;: &quot;2022-02-08&quot;,
          &quot;DepartureTime&quot;: &quot;17:40:00&quot;,
          &quot;equipmentcode&quot;: &quot;333&quot;,
          &quot;equipmentname&quot;: &quot;&quot;,
          &quot;farebase&quot;: &quot;UN3FEST/FB00&quot;,
          &quot;faretype&quot;: &quot;Negotiated&quot;,
          &quot;FlightNumber&quot;: &quot;1972&quot;,
          &quot;freebaggageallowance&quot;: &quot;&quot;,
          &quot;freeseats&quot;: 9,
          &quot;mealcode&quot;: &quot;&quot;,
          &quot;subfaretype&quot;: &quot;Cat35&quot;,
          &quot;journeyDuration&quot;: 0
      },
      {
          &quot;id&quot;: 1,
          &quot;availstring&quot;: &quot;PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X&quot;,
          &quot;flightType&quot;: &quot;&quot;,
          &quot;ArrivalAirportCode&quot;: &quot;DAC&quot;,
          &quot;arrivaldatetime&quot;: &quot;2022-02-09T13:55:00&quot;,
          &quot;ArrivalDate&quot;: &quot;2022-02-09&quot;,
          &quot;ArrivalTime&quot;: &quot;13:55:00&quot;,
          &quot;bookingclass&quot;: &quot;U&quot;,
          &quot;cabinclass&quot;: &quot;Y&quot;,
          &quot;CabinClass&quot;: &quot;Economy&quot;,
          &quot;OperatingAirlineCode&quot;: &quot;TK&quot;,
          &quot;image&quot;: &quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,
          &quot;DepartureAirportCode&quot;: &quot;IST&quot;,
          &quot;departuredatetime&quot;: &quot;2022-02-09T03:35:00&quot;,
          &quot;DepartureDate&quot;: &quot;2022-02-09&quot;,
          &quot;DepartureTime&quot;: &quot;03:35:00&quot;,
          &quot;equipmentcode&quot;: &quot;333&quot;,
          &quot;equipmentname&quot;: &quot;&quot;,
          &quot;farebase&quot;: &quot;UN3FEST/FB00&quot;,
          &quot;faretype&quot;: &quot;Negotiated&quot;,
          &quot;FlightNumber&quot;: &quot;712&quot;,
          &quot;freebaggageallowance&quot;: &quot;&quot;,
          &quot;freeseats&quot;: 9,
          &quot;mealcode&quot;: &quot;&quot;,
          &quot;subfaretype&quot;: &quot;Cat35&quot;,
          &quot;journeyDuration&quot;: 0
      },
      {
          &quot;id&quot;: 2,
          &quot;availstring&quot;: &quot;PUB @1|DAC|TK+723+202202212330+|TK+1979+202202220850+|LHR@@AVL:X|X|X|X&quot;,
          &quot;flightType&quot;: &quot;&quot;,
          &quot;ArrivalAirportCode&quot;: &quot;IST&quot;,
          &quot;arrivaldatetime&quot;: &quot;2022-02-22T05:40:00&quot;,
          &quot;ArrivalDate&quot;: &quot;2022-02-22&quot;,
          &quot;ArrivalTime&quot;: &quot;05:40:00&quot;,
          &quot;bookingclass&quot;: &quot;T&quot;,
          &quot;cabinclass&quot;: &quot;Y&quot;,
          &quot;CabinClass&quot;: &quot;Economy&quot;,
          &quot;OperatingAirlineCode&quot;: &quot;TK&quot;,
          &quot;image&quot;: &quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,
          &quot;DepartureAirportCode&quot;: &quot;DAC&quot;,
          &quot;departuredatetime&quot;: &quot;2022-02-21T23:30:00&quot;,
          &quot;DepartureDate&quot;: &quot;2022-02-21&quot;,
          &quot;DepartureTime&quot;: &quot;23:30:00&quot;,
          &quot;equipmentcode&quot;: &quot;333&quot;,
          &quot;equipmentname&quot;: &quot;&quot;,
          &quot;farebase&quot;: &quot;TLXN2XPC/FB05&quot;,
          &quot;faretype&quot;: &quot;Negotiated&quot;,
          &quot;FlightNumber&quot;: &quot;723&quot;,
          &quot;freebaggageallowance&quot;: &quot;&quot;,
          &quot;freeseats&quot;: 9,
          &quot;mealcode&quot;: &quot;&quot;,
          &quot;subfaretype&quot;: &quot;Cat35&quot;,
          &quot;journeyDuration&quot;: 0
      },
      {
          &quot;id&quot;: 2,
          &quot;availstring&quot;: &quot;PUB @1|DAC|TK+723+202202212330+|TK+1979+202202220850+|LHR@@AVL:X|X|X|X&quot;,
          &quot;flightType&quot;: &quot;&quot;,
          &quot;ArrivalAirportCode&quot;: &quot;LHR&quot;,
          &quot;arrivaldatetime&quot;: &quot;2022-02-22T09:55:00&quot;,
          &quot;ArrivalDate&quot;: &quot;2022-02-22&quot;,
          &quot;ArrivalTime&quot;: &quot;09:55:00&quot;,
          &quot;bookingclass&quot;: &quot;T&quot;,
          &quot;cabinclass&quot;: &quot;Y&quot;,
          &quot;CabinClass&quot;: &quot;Economy&quot;,
          &quot;OperatingAirlineCode&quot;: &quot;TK&quot;,
          &quot;image&quot;: &quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,
          &quot;DepartureAirportCode&quot;: &quot;IST&quot;,
          &quot;departuredatetime&quot;: &quot;2022-02-22T08:50:00&quot;,
          &quot;DepartureDate&quot;: &quot;2022-02-22&quot;,
          &quot;DepartureTime&quot;: &quot;08:50:00&quot;,
          &quot;equipmentcode&quot;: &quot;333&quot;,
          &quot;equipmentname&quot;: &quot;&quot;,
          &quot;farebase&quot;: &quot;TLXN2XPC/FB05&quot;,
          &quot;faretype&quot;: &quot;Negotiated&quot;,
          &quot;FlightNumber&quot;: &quot;1979&quot;,
          &quot;freebaggageallowance&quot;: &quot;&quot;,
          &quot;freeseats&quot;: 9,
          &quot;mealcode&quot;: &quot;&quot;,
          &quot;subfaretype&quot;: &quot;Cat35&quot;,
          &quot;journeyDuration&quot;: 0
      },
      {
          &quot;id&quot;: 1,
          &quot;availstring&quot;: &quot;TK-1972-LHR-IST-202202081740-MG:O@C:TK@|TK-712-IST-DAC-202202090335-MG:I@C:TK@||LEG=1&quot;,
          &quot;flightType&quot;: &quot;&quot;,
          &quot;ArrivalAirportCode&quot;: &quot;IST&quot;,
          &quot;arrivaldatetime&quot;: &quot;2022-02-09T00:30:00&quot;,
          &quot;ArrivalDate&quot;: &quot;2022-02-09&quot;,
          &quot;ArrivalTime&quot;: &quot;00:30:00&quot;,
          &quot;bookingclass&quot;: &quot;U&quot;,
          &quot;cabinclass&quot;: &quot;Y&quot;,
          &quot;CabinClass&quot;: &quot;Economy&quot;,
          &quot;OperatingAirlineCode&quot;: &quot;TK&quot;,
          &quot;image&quot;: &quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,
          &quot;DepartureAirportCode&quot;: &quot;LHR&quot;,
          &quot;departuredatetime&quot;: &quot;2022-02-08T17:40:00&quot;,
          &quot;DepartureDate&quot;: &quot;2022-02-08&quot;,
          &quot;DepartureTime&quot;: &quot;17:40:00&quot;,
          &quot;equipmentcode&quot;: &quot;333&quot;,
          &quot;equipmentname&quot;: &quot;&quot;,
          &quot;farebase&quot;: &quot;UN3FEST&quot;,
          &quot;faretype&quot;: &quot;Published&quot;,
          &quot;FlightNumber&quot;: &quot;1972&quot;,
          &quot;freebaggageallowance&quot;: &quot;&quot;,
          &quot;freeseats&quot;: 9,
          &quot;mealcode&quot;: &quot;&quot;,
          &quot;subfaretype&quot;: &quot;Standard&quot;,
          &quot;journeyDuration&quot;: 0
      }
  ]
  </code></pre>
  <p>I want to append or merge 2 json data .
  I wrote following code
  :</p>
  <pre class="lang-golang prettyprint-override"><code>airsegmentss := []models.Airsegments{}
  for _, flt := range flights {
      for _, arg := range airsegments {
          if arg.Availstring == flt.Availstring {
              airsegmentss = append(airsegmentss, arg)
              flightss := models.Flights{
                  Airsegments: airsegmentss,
              }
              fmt.Println(flightss)
              flightssJson, err := json.Marshal(flightss)
              if err != nil {
                  panic(err)
              }
              fmt.Println(string(flightssJson))
          }
      }
  }
  </code></pre>
  <p>It gives following error which is not valid:</p>
  <pre class="lang-json prettyprint-override"><code>{0      0     0 0     [{1 PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X  IST 2022-02-09T00:30:00 2022-02-09 00:30:00 U Y Economy TK https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png LHR 2022-02-08T17:40:00 2022-02-08 17:40:00 333  UN3FEST/FB00 Negotiated 1972  9  Cat35 0}]}
  {&quot;id&quot;:0,&quot;availstring&quot;:&quot;&quot;,&quot;carrierCode&quot;:&quot;&quot;,&quot;outboundAirlineCode&quot;:&quot;&quot;,&quot;image&quot;:&quot;&quot;,&quot;legtraveltime&quot;:&quot;&quot;,&quot;totalJourneyTime&quot;:0,&quot;recordSet&quot;:&quot;&quot;,&quot;lastTicketingDate&quot;:&quot;&quot;,&quot;legFareClass&quot;:&quot;&quot;,&quot;supportedfunctions&quot;:&quot;&quot;,&quot;requirementValues&quot;:0,&quot;numStops&quot;:0,&quot;departureDate&quot;:&quot;&quot;,&quot;origin&quot;:&quot;&quot;,&quot;arrivalDate&quot;:&quot;&quot;,&quot;destination&quot;:&quot;&quot;,&quot;airsegments&quot;:[{&quot;id&quot;:1,&quot;availstring&quot;:&quot;PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X&quot;,&quot;flightType&quot;:&quot;&quot;,&quot;ArrivalAirportCode&quot;:&quot;IST&quot;,&quot;arrivaldatetime&quot;:&quot;2022-02-09T00:30:00&quot;,&quot;ArrivalDate&quot;:&quot;2022-02-09&quot;,&quot;ArrivalTime&quot;:&quot;00:30:00&quot;,&quot;bookingclass&quot;:&quot;U&quot;,&quot;cabinclass&quot;:&quot;Y&quot;,&quot;CabinClass&quot;:&quot;Economy&quot;,&quot;OperatingAirlineCode&quot;:&quot;TK&quot;,&quot;image&quot;:&quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,&quot;DepartureAirportCode&quot;:&quot;LHR&quot;,&quot;departuredatetime&quot;:&quot;2022-02-08T17:40:00&quot;,&quot;DepartureDate&quot;:&quot;2022-02-08&quot;,&quot;DepartureTime&quot;:&quot;17:40:00&quot;,&quot;equipmentcode&quot;:&quot;333&quot;,&quot;equipmentname&quot;:&quot;&quot;,&quot;farebase&quot;:&quot;UN3FEST/FB00&quot;,&quot;faretype&quot;:&quot;Negotiated&quot;,&quot;FlightNumber&quot;:&quot;1972&quot;,&quot;freebaggageallowance&quot;:&quot;&quot;,&quot;freeseats&quot;:9,&quot;mealcode&quot;:&quot;&quot;,&quot;subfaretype&quot;:&quot;Cat35&quot;,&quot;journeyDuration&quot;:0}]}
  {0      0     0 0     [{1 PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X  IST 2022-02-09T00:30:00 2022-02-09 00:30:00 U Y Economy TK https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png LHR 2022-02-08T17:40:00 2022-02-08 17:40:00 333  UN3FEST/FB00 Negotiated 1972  9  Cat35 0} {1 PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X  DAC 2022-02-09T13:55:00 2022-02-09 13:55:00 U Y Economy TK https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png IST 2022-02-09T03:35:00 2022-02-09 03:35:00 333  UN3FEST/FB00 Negotiated 712  9  Cat35 0}]}
  {&quot;id&quot;:0,&quot;availstring&quot;:&quot;&quot;,&quot;carrierCode&quot;:&quot;&quot;,&quot;outboundAirlineCode&quot;:&quot;&quot;,&quot;image&quot;:&quot;&quot;,&quot;legtraveltime&quot;:&quot;&quot;,&quot;totalJourneyTime&quot;:0,&quot;recordSet&quot;:&quot;&quot;,&quot;lastTicketingDate&quot;:&quot;&quot;,&quot;legFareClass&quot;:&quot;&quot;,&quot;supportedfunctions&quot;:&quot;&quot;,&quot;requirementValues&quot;:0,&quot;numStops&quot;:0,&quot;departureDate&quot;:&quot;&quot;,&quot;origin&quot;:&quot;&quot;,&quot;arrivalDate&quot;:&quot;&quot;,&quot;destination&quot;:&quot;&quot;,&quot;airsegments&quot;:[{&quot;id&quot;:1,&quot;availstring&quot;:&quot;PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X&quot;,&quot;flightType&quot;:&quot;&quot;,&quot;ArrivalAirportCode&quot;:&quot;IST&quot;,&quot;arrivaldatetime&quot;:&quot;2022-02-09T00:30:00&quot;,&quot;ArrivalDate&quot;:&quot;2022-02-09&quot;,&quot;ArrivalTime&quot;:&quot;00:30:00&quot;,&quot;bookingclass&quot;:&quot;U&quot;,&quot;cabinclass&quot;:&quot;Y&quot;,&quot;CabinClass&quot;:&quot;Economy&quot;,&quot;OperatingAirlineCode&quot;:&quot;TK&quot;,&quot;image&quot;:&quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,&quot;DepartureAirportCode&quot;:&quot;LHR&quot;,&quot;departuredatetime&quot;:&quot;2022-02-08T17:40:00&quot;,&quot;DepartureDate&quot;:&quot;2022-02-08&quot;,&quot;DepartureTime&quot;:&quot;17:40:00&quot;,&quot;equipmentcode&quot;:&quot;333&quot;,&quot;equipmentname&quot;:&quot;&quot;,&quot;farebase&quot;:&quot;UN3FEST/FB00&quot;,&quot;faretype&quot;:&quot;Negotiated&quot;,&quot;FlightNumber&quot;:&quot;1972&quot;,&quot;freebaggageallowance&quot;:&quot;&quot;,&quot;freeseats&quot;:9,&quot;mealcode&quot;:&quot;&quot;,&quot;subfaretype&quot;:&quot;Cat35&quot;,&quot;journeyDuration&quot;:0},{&quot;id&quot;:1,&quot;availstring&quot;:&quot;PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X&quot;,&quot;flightType&quot;:&quot;&quot;,&quot;ArrivalAirportCode&quot;:&quot;DAC&quot;,&quot;arrivaldatetime&quot;:&quot;2022-02-09T13:55:00&quot;,&quot;ArrivalDate&quot;:&quot;2022-02-09&quot;,&quot;ArrivalTime&quot;:&quot;13:55:00&quot;,&quot;bookingclass&quot;:&quot;U&quot;,&quot;cabinclass&quot;:&quot;Y&quot;,&quot;CabinClass&quot;:&quot;Economy&quot;,&quot;OperatingAirlineCode&quot;:&quot;TK&quot;,&quot;image&quot;:&quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,&quot;DepartureAirportCode&quot;:&quot;IST&quot;,&quot;departuredatetime&quot;:&quot;2022-02-09T03:35:00&quot;,&quot;DepartureDate&quot;:&quot;2022-02-09&quot;,&quot;DepartureTime&quot;:&quot;03:35:00&quot;,&quot;equipmentcode&quot;:&quot;333&quot;,&quot;equipmentname&quot;:&quot;&quot;,&quot;farebase&quot;:&quot;UN3FEST/FB00&quot;,&quot;faretype&quot;:&quot;Negotiated&quot;,&quot;FlightNumber&quot;:&quot;712&quot;,&quot;freebaggageallowance&quot;:&quot;&quot;,&quot;freeseats&quot;:9,&quot;mealcode&quot;:&quot;&quot;,&quot;subfaretype&quot;:&quot;Cat35&quot;,&quot;journeyDuration&quot;:0}]}
  {0      0     0 0     [{1 PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X  IST 2022-02-09T00:30:00 2022-02-09 00:30:00 U Y Economy TK https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png LHR 2022-02-08T17:40:00 2022-02-08 17:40:00 333  UN3FEST/FB00 Negotiated 1972  9  Cat35 0}]}
  {&quot;id&quot;:0,&quot;availstring&quot;:&quot;&quot;,&quot;carrierCode&quot;:&quot;&quot;,&quot;outboundAirlineCode&quot;:&quot;&quot;,&quot;image&quot;:&quot;&quot;,&quot;legtraveltime&quot;:&quot;&quot;,&quot;totalJourneyTime&quot;:0,&quot;recordSet&quot;:&quot;&quot;,&quot;lastTicketingDate&quot;:&quot;&quot;,&quot;legFareClass&quot;:&quot;&quot;,&quot;supportedfunctions&quot;:&quot;&quot;,&quot;requirementValues&quot;:0,&quot;numStops&quot;:0,&quot;departureDate&quot;:&quot;&quot;,&quot;origin&quot;:&quot;&quot;,&quot;arrivalDate&quot;:&quot;&quot;,&quot;destination&quot;:&quot;&quot;,&quot;airsegments&quot;:[{&quot;id&quot;:1,&quot;availstring&quot;:&quot;PUB @1|LHR|TK+1972+202202081740+|TK+712+202202090335+|DAC@@AVL:X|X|X|X&quot;,&quot;flightType&quot;:&quot;&quot;,&quot;ArrivalAirportCode&quot;:&quot;IST&quot;,&quot;arrivaldatetime&quot;:&quot;2022-02-09T00:30:00&quot;,&quot;ArrivalDate&quot;:&quot;2022-02-09&quot;,&quot;ArrivalTime&quot;:&quot;00:30:00&quot;,&quot;bookingclass&quot;:&quot;U&quot;,&quot;cabinclass&quot;:&quot;Y&quot;,&quot;CabinClass&quot;:&quot;Economy&quot;,&quot;OperatingAirlineCode&quot;:&quot;TK&quot;,&quot;image&quot;:&quot;https://travnet-tse-bucket.s3.eu-west-2.amazonaws.com/airline-logo/TK.png&quot;,&quot;DepartureAirportCode&quot;:&quot;LHR&quot;,&quot;departuredatetime&quot;:&quot;2022-02-08T17:40:00&quot;,&quot;DepartureDate&quot;:&quot;2022-02-08&quot;,&quot;DepartureTime&quot;:&quot;17:40:00&quot;,&quot;equipmentcode&quot;:&quot;333&quot;,&quot;equipmentname&quot;:&quot;&quot;,&quot;farebase&quot;:&quot;UN3FEST/FB00&quot;,&quot;faretype&quot;:&quot;Negotiated&quot;,&quot;FlightNumber&quot;:&quot;1972&quot;,&quot;freebaggageallowance&quot;:&quot;&quot;,&quot;freeseats&quot;:9,&quot;mealcode&quot;:&quot;&quot;,&quot;subfaretype&quot;:&quot;Cat35&quot;,&quot;journeyDuration&quot;:0}]}
  
  ]}
  
  </code></pre>
  <p>How do I append 2 or more json data . It should check if conditions and if two id of 2 or more json data matches then one json data should append with another one.</p>
  <p>Note:
  In php code:</p>
  <pre class="lang-php prettyprint-override"><code>$air  = array();
  $flights = $flights-&gt;map(function($item) use ($airsegments){
                foreach($airsegments as $airsegment)
                {
                  if(preg_replace('/[^A-Za-z0-9\-]/', '',($airsegment['availstring'].''.$airsegment['id']))
                    == preg_replace('/[^A-Za-z0-9\-]/', '',($item['availstring'].''.$item['id'])))
                  {
                    $air[]   = $airsegment;
                    }
                   }
                  return collect($item)-&gt;put('airsegments', $air);
                });
  </code></pre>
  <p>The above code works perfectly in php. Since I am rewriting the whole php code in golang.</p>