Scenario : Deserialize the JSON format data using wrapper class. I have JSON data and wrapper class for the JSON. I want to see value for one of the property in inner class of the wrapper class. But I cannot able to access the inner class in my batch class. Below are the sample wrapper class and batch class
Wrapper class :
Public class JSON2ApexWrapperClass{
public class Aliases
{
public string href { get; set; }
}
public class Comments
{
public string countat { get; set; }
public string href { get; set; }
}
public static JSON2ApexWrapperClass parse(String json) {
return (JSON2ApexWrapperClass) System.JSON.deserialize(json, JSON2ApexWrapperClass.class);
}
}
Batch Class :
global void execute(Database.BatchableContext BC, List<Account> scope){
string jsonResult = 'body of json';
JSON2ApexWrapperClass jsonDeserialize = JSON2ApexWrapperClass.parse(jsonResult);
system.debug('******* Deserialized *********'+jsonDeserialize);
system.debug('******* Deserialized *********'+jsonDeserialize.Comments); //I CANNOT ABLE TO ACCESS COMMENTS CLASS
}
sample JSON string :
{
"@count":"1",
"@querycount":"1",
"@ranking":"adaptive",
"mindTouchPage":{
"id":"333",
"guid":"01955249d38a4c8681940f8e84b55b90",
"draftstate":"inactive",
"href":"https://sampleTest.us/@api/poki/pages/333?redirects=0",
"deleted":"false",
"@unpublish":"true",
"@revision":"2",
"@score":"1",
"aliases":{
"href":"https://sampleTest.us/@api/poki/pages/333/aliases"
},
"comments":{
"@count":"0",
"href":"https://sampleTest.us/@api/poki/pages/333/comments"
}
}
}
How to access inner class in batch class and how to see the deserialized values of comments class.