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
hiteshwar marnihiteshwar marni 

jsonparsing help

{"Message":"Number of Post office(s) found: 21","Status":"Success","PostOffice":[{"Name":"Baroda House","Description":"","BranchType":"Sub Post Office","DeliveryStatus":"Non-Delivery","Taluk":"New Delhi","Circle":"New Delhi","District":"Central Delhi","Division":"New Delhi Central","Region":"Delhi","State":"Delhi","Country":"India"}]}

The above is my json string.
I have written the following code deserialize it

global class wrapper{
global class parserr
    {
       global string Message{get;set;}
       global string Status{get;set;} 
       global list<postoffice>po{get;set;}
    }
    global class postoffice
    {
        global string name{get;set;}
        global string Description{get;set;}
        global string BranchType{get;set;}
        global string DeliveryStatus{get;set;}
        global string Taluk{get;set;}
        global string Circle{get;set;}
        global string District{get;set;}
        global string Division{get;set;}
        global string Region{get;set;}
        global string state{get;set;}
        global string country{get;set;}
    }
}

 p= (wrapper.paresrr)JSON.deserialize(JSONresponse, wrapper.parserr.class);
I'm getting the values of Message and status correctly. But list<postoffice> po is getting as null although values are coming into response.And also I want the values in postoffice class also.
Thanks
Best Answer chosen by hiteshwar marni
Nayana KNayana K
global class wrapper{
global class parserr
    {
       global string Message{get;set;}
       global string Status{get;set;} 
       global list<postoffice> PostOffice{get;set;}
    }
    global class postoffice
    {
        global string Name{get;set;}
        global string Description{get;set;}
        global string BranchType{get;set;}
        global string DeliveryStatus{get;set;}
        global string Taluk{get;set;}
        global string Circle{get;set;}
        global string District{get;set;}
        global string Division{get;set;}
        global string Region{get;set;}
        global string State{get;set;}
        global string Country{get;set;}
    }
}

Please try this once

All Answers

Nayana KNayana K
global class wrapper{
global class parserr
    {
       global string Message{get;set;}
       global string Status{get;set;} 
       global list<postoffice> PostOffice{get;set;}
    }
    global class postoffice
    {
        global string Name{get;set;}
        global string Description{get;set;}
        global string BranchType{get;set;}
        global string DeliveryStatus{get;set;}
        global string Taluk{get;set;}
        global string Circle{get;set;}
        global string District{get;set;}
        global string Division{get;set;}
        global string Region{get;set;}
        global string State{get;set;}
        global string Country{get;set;}
    }
}

Please try this once
This was selected as the best answer
hiteshwar marnihiteshwar marni
Thanks Nayana your suggstion helped