gson class:
import com.google.gson.*;
myJson:
{
"time": "notime",
"query": {
"pages": {
"18302": {
"title": "Car",
"pagelanguage": "en"
}
}
}
}
Custom POJO class:
public class MyClass {
public String time;
public Query query;
public class Query {
public ? pages;
//...
}
}
Java code:
Gson gson = new GsonBuilder().create();
MyClass data = gson.fromJson(myJson, MyClass.class);
What Class should i set to my "pages" variable to handle dynamically changing (for exp: "18302") json key?
pagesknown? In other words, will it always be a JSON object withtitleandpagelanguage?Mapwith the value type being a POJO type that fits the JSON object withtitleandpagelanguage.