Skip to content

Instantly share code, notes, and snippets.

@olopsman
Created October 2, 2019 10:09
Show Gist options
  • Save olopsman/4bab5d82a22bc43cbaa57406865f6600 to your computer and use it in GitHub Desktop.
Save olopsman/4bab5d82a22bc43cbaa57406865f6600 to your computer and use it in GitHub Desktop.
Apex JSONdeserialize to a GetPerson class from array
String input = '[{"name":"paulo","age":42, "car" : {"model" : "outlander", "year" : "2016"}}, {"name":"tin","age":40, "car" : {"model" : "crv", "year" : "2004"}}]';
List<GetPerson> person = (List<GetPerson>) JSON.deserialize(input, List<GetPerson>.class);
system.assertEquals(person.size(), 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment