I have JSON String that read as below
{ "Status":"Clear", "Class": [{ <br>
{"name":"personA", "available" : 1}, <br>
{"name":"personB", "available" : 0}, <br>
{"name":"personC", "available" : 0}, <br>
{"name":"personD", "available" : 1} <br>
}] }
How do I deserialize the JSON String above?
I got the idea of using JSONObject to take in whole JSON String into it but no idea how to get the arraylist of object (the list of Class object) and assign to a arraylist<Class>.
Guidance and help are much appreciated.
UPDATED :
SOLVED AND SOLUTION SHOWN
I have solved this question but I think I have to explain how and why I used such solution.
So to further explain my question, this is an json string that originally an object that got serialized and sent from a webservice to my apps.
the original object is like this :
public class StatusJson
{
public String Status { get; set; }
public List<Class> Class { get; set; }
}
So what I have to do is just declare an exactly same class in my android then use this code
statusJson statusJSON=g.fromJson(JSonString,StatusJson.class);
which will automatically parse the json string to the exact same class format.
Hope this will help you guys too if you are directly sending a JSON serialized class like me.