I have the Json string coming from DB field and I want that to be converted to Apex. I tried the below code but that only returns the first instance in json string.
{
"firstname":"abc",
"Lastname": "xyz",
},
{
"firstname":"abc1",
"Lastname": "xyz1",
}
Apex class that i am using is
public class JSON2Apex {
public String firstname;
public String Lastname;
public static JSON2Apex parse(String json) {
return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
}
}
And how i am calling is
JSON2Apex obj = JSON2Apex.parse(json);
And it returns only
JSON2Apex:[firstname= abc, Lastname=xyz]
Can anyone suggests where am i doing wrong.I know we need to create List to hold all items but not sure where and how.