1
0

Fix string pair list type converter (#971)

This commit is contained in:
Mikołaj Pich
2020-09-29 21:02:49 +02:00
committed by GitHub
parent 11487e77ca
commit 1f0f6b3e51
3 changed files with 10 additions and 5 deletions

View File

@ -56,11 +56,11 @@ object PairAdapterFactory : JsonAdapter.Factory {
private fun deserializeGsonPair(reader: JsonReader): List<Pair<String, String>>? {
val list = listAdapter.fromJson(reader) ?: return null
require(list.size == 2 || list.isEmpty()) {
"pair with more or less than two elements: $list"
}
return list.map {
require(it.size == 2) {
"pair with more or less than two elements: $list"
}
it["first"].orEmpty() to it["second"].orEmpty()
}
}