How to deserialize the following Json using Google GSON? I tried to deserialize the following JSON:
{
"version": "1.0",
"data": {
"person1": {
"detailsOffather": {
"name": "xyz",
"phone": "8000452234",
"address1": "abc xyz",
"address 2": "abcd wxyz",
"gender": "male"
},
"detailsOfmother": {
"name": "123",
"phone": "9988776644",
"address1": "st johns street",
"address 2": "canada",
"gender": "female"
},
"detailsOfSon": {
"name": "abc",
"phone": "8877665544",
"address1": "church street",
"address 2": "canada",
"gender": "male"
}
},
"person2": {
"detailsOffather": {
"name": "xyz",
"phone": "8000452234",
"address1": "abc xyz",
"address 2": "abcd wxyz",
"gender": "male"
},
"detailsOfmother": {
"name": "123",
"phone": "9988776644",
"address1": "st johns street",
"address 2": "canada",
"gender": "female"
},
"detailsOfSon": {
"name": "abc",
"phone": "8877665544",
"address1": "church street",
"address 2": "canada",
"gender": "male"
}
},
"person3": {
"detailsOffather": {
"name": "xyz",
"phone": "8000452234",
"address1": "abc xyz",
"address 2": "abcd wxyz",
"gender": "male"
},
"detailsOfmother": {
"name": "123",
"phone": "9988776644",
"address1": "st johns street",
"address 2": "canada",
"gender": "female"
},
"detailsOfSon": {
"name": "abc",
"phone": "8877665544",
"address1": "church street",
"address 2": "canada",
"gender": "male"
}
}
}
}
using the following class structure:
class information{
String version;
HashMap<String,Details> data;
}
class Details
{
HashMap<String,String> details;
}
Using Google GSON as follows :
Gson gson=new Gson();
gson.fromJson(JsonFile,Information.class)
However, I am not able to deserialize it, can someone help me with it?Note : I need to maintain the data types and the structure of Json.