I have a JSON file that is an export of my Sqlite DB of my Android app. It contains different lists with different types:
{
"territories": [
{
"created": "Mar 17, 2018 8:30:28 PM",
"id": 1,
"name": "tt",
"parentId": 0
},
{
"created": "Mar 17, 2018 8:45:58 PM",
"id": 2,
"name": "aa",
"parentId": 0
}
],
"streets": [
{
"created": "Mar 18, 2018 7:10:23 AM",
"id": 1,
"name": "bb",
"parentId": 2
}
],
"buildings": [
{
"created": "Mar 18, 2018 7:10:28 AM",
"id": 1,
"name": "cc",
"parentId": 1
}
],
"flats": [
{
"created": "Mar 18, 2018 7:10:36 AM",
"id": 1,
"name": "dd",
"parentId": 1
}
],
"vists": [
{
"buildingId": 1,
"categoryId": 6,
"dateTime": "Mar 18, 2018 7:10:00 AM",
"description": "Xxxxx",
"flatId": 1,
"id": 1,
"streetId": 1,
"territoryId": 2
}
]
}
I know how to parse a JSON file containing a single list with the same objects:
Gson gson = new Gson();
List<DbBaseType> territoryList = null;
try {
territoryList = gson.fromJson(new FileReader("path/my.export"),
new TypeToken<List<DbBaseType>>(){}.getType());
} catch (FileNotFoundException e) {
//...
}
But how to parse a file containg different lists with different objects?