function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vignesh balasubramanian 14vignesh balasubramanian 14 

How to display de-serialized value in apex controller from wrapper class (Very Urgent)

Hi Everyone,
This is my wrapper class,
public class JSON2Apex2 {
    public class Address_components {
        public String long_name;
        public String short_name;
        public List<String> types;
    }
    
    public class Geometry {
        public Location location;
        public String location_type;
        public Viewport viewport;
    }
    
    public class JSON2Apex {
        public List<Results> results;
        public String status;
    }
    
    public class Results {
        public List<Address_components> address_components;
        public String formatted_address;
        public Geometry geometry;
        public String place_id;
        public List<String> types;
    }
    
    public class Viewport {
        public Location northeast;
        public Location southwest;
    }
    
    public class Location {
        public Double lat{get;set;}
        public Double lng{get;set;}
    }
    public Location loc{get;set;}
    public static JSON2Apex2 parse(String json) {
        return (JSON2Apex2) System.JSON.deserialize(json, JSON2Apex2.class);
    }
}

This is my apex controller,
 
public class latlan_AC 
{
    static  List<Contact> contlist=new List<Contact>();
    String address;
    public  static JSON2Apex2 wrapper {get;set;}
    public latlan_AC(List<Contact> conlist)
    {
        for(Contact cntlist:conlist)
        {
            string jsonString = JSON.serializePretty(cntlist);
            callout(jsonString);
        }
        
        //callout(jsonString);
    }
    @future(callout=true)
    public static void callout(String  cnt1)
    {
        contact cnt =  (contact)JSON.deserializeStrict(cnt1, contact.class);
        String address=cnt.MailingStreet +','+cnt.MailingCity+','+cnt.MailingState+','+cnt.MailingCountry+','+cnt.MailingPostalCode;
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://maps.googleapis.com/maps/api/geocode/json?address='+address+'&key=AIzaSyDvf7W2SWXwUPXy8X2PSIGM6NwVusZywx4');
        req.setMethod('GET');
        req.setHeader('Content-Type', 'application/json');
        req.setHeader('Accept','application/json');
        HTTPResponse res = http.send(req);
        if(res.getStatusCode()==200)
        {
            wrapper = (JSON2Apex2) JSON.deserialize(res.getBody(), JSON2Apex2.class);
            system.debug('result'+ wrapper); //Here I got null value only how to display lat and lng values
        }
    }
}
My requiremayent is to display  public Double lat{get;set;} public Double lng{get;set;} values in apex controller

Thanks in Advance,
Vignesh.B