• Jordan Schatz
  • 0 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0
I am trying to deserialize some JSON into a custom class. If I deserlize just a single object, it works, but when wrapped in a list, it fails.

Here is an example:
public class attendanceWrapperClass {
    @AuraEnabled public Case eachContact{get;set;}
    @AuraEnabled public Attendance_Breakfast_Lunch_Snack__c eachAttendance{get;set;}
    @AuraEnabled public List<Attendance_Breakfast_Lunch_Snack__c> previousAttendanceRecordsList{get;set;}

string wrapperListItems = '[{"eachAttendance":{"Attendance_Code__c":"Y - Yes"},"eachContact":{"Client__c":"0036F00002xYORdQAO","Admission_Pathway_Site__c":"Wolverine Center","WHS_Treatment_Unit__c":"WC CMO Respite","WHS_Treatment_Program__c":"Wolverine Center Respite","Id":"5006F0000240Jv2QAE","Client__r":{"Name":"Cedric Russ","FirstName":"Cedric","LastName":"Russ","Id":"0036F00002xYORdQAO"}}}]';
list<attendanceWrapperClass> wrapperList = (List<attendanceWrapperClass>)JSON.deserialize(wrapperListItems,List<attendanceWrapperClass>.class);

The error I get is System.JSONException: Expected attendanceWrapperClass but found } at [line:1, column:369] basically it errors when the first item in the list ends.

What am I doing wrong?