AnsweredAssumed Answered

Update JSON Response - Recommended Way

Question asked by Maruti.Chennamsetty on Mar 16, 2016
Latest reply on Mar 20, 2016 by Mark_HE

Friends,

 

One of the API has been integrated with Google API. The following is the JSON response from Google API geocode. What is the best way to create a new response by extracting some JSON fields/data  to satisfy an use case.

 

Appreciate your valuable input.

 

Original responseExpected (Example)

 

{

   "results": [   {

      "address_components":       [

                  {

            "long_name": "330",

            "short_name": "330",

            "types": ["street_number"]

         },

                  {

            "long_name": "South Goldenrod Drive",

            "short_name": "S Goldenrod Dr",

            "types": ["route"]

         },

                  {

            "long_name": "Sun Prairie",

            "short_name": "Sun Prairie",

            "types":             [

               "locality",

               "political"

            ]

         },

                  {

            "long_name": "Dane County",

            "short_name": "Dane County",

            "types":             [

               "administrative_area_level_2",

               "political"

            ]

         },

                  {

            "long_name": "Wisconsin",

            "short_name": "WI",

            "types":             [

               "administrative_area_level_1",

               "political"

            ]

         },

                  {

            "long_name": "United States",

            "short_name": "US",

            "types":             [

               "country",

               "political"

            ]

         },

                  {

            "long_name": "53590",

            "short_name": "53590",

            "types": ["postal_code"]

         }

      ],

      "formatted_address": "330 S Goldenrod Dr, Sun Prairie, WI 53590, USA",

      "geometry":       {

         "location":          {

            "lat": 43.172981,

            "lng": -89.269177

         },

         "location_type": "ROOFTOP",

         "viewport":          {

            "northeast":             {

               "lat": 43.1743299802915,

               "lng": -89.26782801970849

            },

            "southwest":             {

               "lat": 43.1716320197085,

               "lng": -89.2705259802915

            }

         }

      },

      "place_id": "ChIJK7R8jXX4BogRoXwyLznnCu8",

      "types": ["street_address"]

   }],

   "status": "OK"

}

   "results":[ 

      { 

         "formatted_addresses":[ 

            { 

               "addressLine1":"330",

               "city":"330",

               "stateCode":"WI",

        "zip" : "53590"

            },

            { 

               "addressLine1":"330",

               "city":"330",

               "stateCode":"WI",

        "zip" : "53590"

            }

         ]

      }

   ]

}

 

Outcomes