I need to store my schedule in a single JSON file so I can load it again to my app if needed. The schedules are stored using the following three classes:
data class DayScheduleItem(
var hourAndMin: Calendar = Calendar.getInstance(),
): ScheduleItem()
data class ExceptionItem(
var fromDate: Calendar = Calendar.getInstance(),
var toDate: Calendar = Calendar.getInstance(),
): ScheduleItem()
data class WeekDayScheduleItem(
var name: String,
): ScheduleItem() {
var isOpen: Boolean = false
}
There is then the super class:
class ScheduleItem {
var id: Int? = null
get() = field
set(value) {
field= value
}
var data: List<Byte> = emptyList()
get() = field
set(value) {
field = value
}
}
Now I have a list as follows:
[
[
DayScheduleItem1,
DayScheduleItem2
],
[
WeekDayScheduleItem1,
WeekDayScheduleItem2,
WeekDayScheduleItem3,
WeekDayScheduleItem4
],
[
]
]
The questions are:
- How to parse this json using GSON.fromJson()?
- Do I need to simplify my classes?
- Do I need to use another library like Moshi?
- Shall I change the structure of my JSON?