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
neao18neao18 

Object of a Object return null!!

Hi all,

 

I may be a stupit question to be asked but here is the senario:

 

1. I have a jsone string and I am parsing it with JSONParser  as

                        

wrapGoogleData inv = (wrapGoogleData)parser.readValueAs(wrapGoogleData.class);
lstwrap.put(inv.id,inv);

 I am getting the parsed string in my class as: 

public class wrapGoogleData{
    
        public string summary{get;set;}
        public string id{get;set;}
        public string status{get;set;}
        public creator creator;
        public start start;
        public endd endd;
        
        public wrapGoogleData(string entnm,string ezid,string sta, creator c,start s,endd e){
            system.debug('****##########***');
            summary= entnm;
            id= ezid;
            status = sta;
            creator = c;
            system.debug('****start***'+s);
            system.debug('****startDate***'+s.datetimed);
            //start = new start(s.datetimed);
            start = s;
            endd = e;
        } 
        public creator getcreatorob(){
            return (creator) creator;
        }
        public start getstartob(){
            return (start) start;
        } 
        public string getstartobdate(){
            return (string) start.datetimed;
        } 
        public endd  getendob(){
            return (endd ) endd;
        } 
    }
    public class creator{
        public string email{get;set;}
        public string displayName{get;set;}
        public string self{get;set;}
    }
    public class start{
        public string datetimed{get;set;}
       /* public start(string str){
            datetimed = str;
        }*/
    }
    public class endd{
        public string datetimed{get;set;}
    }

 2. What i am doing is I am itrating over the map of this wrapper class as: 

 for(wrapGoogleData wpl : lstwrap.values()){
            string getGoogle='';
            getGoogle = getGoogle + 'start  : "' + wpl.getstartob().datetimed +'",';

 This returns a null pointer at the last line: But when I write it as it return a object and not null pointer var: How to get the datetimed variable in this senario???

getGoogle = getGoogle + 'start  : "' + wpl.getstartob() +'",';
Shiv ShankarShiv Shankar

Do this Way

 

(wpl.getstartob()).datetimed

 

neao18neao18

Sorry but that did'nt worked!!