Return empty list on empty value
This commit is contained in:
parent
9f8d59f0d4
commit
106552036e
1 changed files with 5 additions and 1 deletions
|
@ -29,10 +29,14 @@ class Converters {
|
||||||
fun stringListToJson(list: List<String>) = gson.toJson(list)
|
fun stringListToJson(list: List<String>) = gson.toJson(list)
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun attendeeListToJson(list: List<Attendee>) = gson.toJson(list)
|
fun attendeeListToJson(list: List<Attendee>): String = gson.toJson(list)
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun jsonToAttendeeList(value: String): List<Attendee> {
|
fun jsonToAttendeeList(value: String): List<Attendee> {
|
||||||
|
if (value.isEmpty()) {
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
gson.fromJson<ArrayList<Attendee>>(value, attendeeType) ?: ArrayList()
|
gson.fromJson<ArrayList<Attendee>>(value, attendeeType) ?: ArrayList()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
Loading…
Reference in a new issue