+ Start a Discussion
sairama kanthsairama kanth 

How to capture address from Google returned json fromat to fill into account billing address fields

How to capture address from Google returned json fromat to fill into account billing address fields
From the below String how to fill Account billing address details automatically 
Here i am unable too parse the long_name,it repeats so how to identify street,District,State,Country,Pincode and fill all these details into Account billing Street,Billing state,Billing city,etc 
{
   "plus_code" : {
      "compound_code" : "9FPP+2M Hyderabad, Telangana, India",
      "global_code" : "7J9W9FPP+2M"
   },
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "19",
               "short_name" : "19",
               "types" : [ "premise" ]
            },
            {
               "long_name" : "Subhash Nagar",
               "short_name" : "Subhash Nagar",
               "types" : [ "political", "sublocality", "sublocality_level_3" ]
            },
            {
               "long_name" : "Badi Chowdi",
               "short_name" : "Badi Chowdi",
               "types" : [ "political", "sublocality", "sublocality_level_2" ]
            },
            {
               "long_name" : "Bahadurpura",
               "short_name" : "Bahadurpura",
               "types" : [ "political", "sublocality", "sublocality_level_1" ]
            },
            {
               "long_name" : "Hyderabad",
               "short_name" : "Hyderabad",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Hyderabad",
               "short_name" : "Hyderabad",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Telangana",
               "short_name" : "Telangana",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "500064",
               "short_name" : "500064",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "19, Subhash Nagar, Badi Chowdi, Bahadurpura, Hyderabad, Telangana 500064, India",
 
Fernando Gonzalez 24Fernando Gonzalez 24
You can make an Apex class representing the data structure you are getting in the json. Then you can use the Apex JSON class by using JSON.deserialize(jsonString, apexType). So once your have your json into an apex object then that's when i would do the processing of those fields that have multiple data in them by disecting the string.