I'm trying to deserialize a List of JSON objects
in Apex
. Here is the JSON being passed:
[
{
"Name":"TestUser1",
"Interview_Information":{
"Interviewer":"JTA Test",
"CandidateStage":"Final ROund",
"Recommendation":"Hire!",
"Candidate_Name":"JTA Test",
"Competency":[
{
"Competency":"Team Player",
"Question":"Describe when you failed on a team",
"Rating":"Advanced",
"Candidate_Name":"JTA Test"
}
]
}
}
]
And here is my APEX code :
public class DeserializeJSON {
public String PDFData {get; set;}
public DeserializeJSON() {
PDFData = '';
}
public void deserialize() {
List<DeserializeJSON.CandidateSummary> allCandidates = (List<DeserializeJSON.CandidateSummary>)JSON.deserialize(PDFData, List<DeserializeJSON.CandidateSummary>.class);
system.debug('allCandidates = '+allCandidates);
}
public class CandidateSummary {
public String Name {get; set;}
public Interview_Information Interview_Information {get; set;}
}
public class Interview_Information {
public String Interviewer;
public String CandidateStage;
public String Recommendation;
public String Candidate_Name;
public List<Competency> Competency;
}
public class Competency {
public String Competency;
public String Question;
public String Rating;
public String Candidate_Name;
}
UPDATE : I updated my code as per the SFDC's suggestion -- none of my debug statements are showing up on dev console now.
DeserializeJSON.deserialize()
method from anywhere.DeserializeJSON deserializeJSON = new DeserializeJSON(); deserializeJSON.PDFData = YOUR_JSON; deserializeJSON.deserialize();
And this method doesn't return anything as of now, I guess you need to adjust the return type as well.