I have Json response (named as jsonResultAsText):
{
"Title": "Hi all",
"IsSecret": false,
"Agents": [
{
"ID": 3,
"Name": "John F"
},
{
"ID": 7,
"Name": "Jack D"
}
]
}
I want to deserialize it using Google's gson library.
I have classes like:
public class JsonResponse {
public String Title;
public boolean IsSecret;
public List<Agent> Agents;
}
public class Agent {
public int ID;
public String Name;
}
I want to get json data into JsonResponse class.
It's the code that I try to achieve:
JsonResponse response =
new Gson().fromJson(jsonResultAsText, JsonResponse.class);
But my Android application gives that classic error: Unfortunately, < app_name > has stopped.
I know that there are plenty examples about serializing/deserializing via gson class, but I could not find similar problem/example.
Thanks in advance.