@@ -22,11 +22,11 @@ import kotlinx.serialization.json.JsonObject
22
22
internal val nonstrictJson =
23
23
Json (
24
24
JsonConfiguration (
25
- isLenient = true ,
26
- ignoreUnknownKeys = true ,
27
- serializeSpecialFloatingPointValues = true ,
28
- useArrayPolymorphism = true
29
- )
25
+ isLenient = true ,
26
+ ignoreUnknownKeys = true ,
27
+ serializeSpecialFloatingPointValues = true ,
28
+ useArrayPolymorphism = true
29
+ )
30
30
)
31
31
32
32
internal inline fun <reified T : Any > String.toObjectNullable (serializer : KSerializer <T >, api : SpotifyApi <* , * >? , json : Json ): T ? = try {
@@ -72,7 +72,8 @@ internal fun <T : Any> String.toPagingObject(
72
72
if (innerObjectName != null || (arbitraryInnerNameAllowed && ! skipInnerNameFirstIfPossible)) {
73
73
val map = this .parseJson {
74
74
val t = (String .serializer() to PagingObject .serializer(tSerializer))
75
- json.parse(MapSerializer (t.first, t.second), this ) }
75
+ json.parse(MapSerializer (t.first, t.second), this )
76
+ }
76
77
return (map[innerObjectName] ? : if (arbitraryInnerNameAllowed) map.keys.firstOrNull()?.let { map[it] }
77
78
? : error(" " ) else error(" " ))
78
79
.apply {
@@ -143,7 +144,8 @@ internal fun <T : Any> String.toCursorBasedPagingObject(
143
144
if (innerObjectName != null || (arbitraryInnerNameAllowed && ! skipInnerNameFirstIfPossible)) {
144
145
val map = this .parseJson {
145
146
val t = (String .serializer() to CursorBasedPagingObject .serializer(tSerializer))
146
- json.parse(MapSerializer (t.first, t.second), this ) }
147
+ json.parse(MapSerializer (t.first, t.second), this )
148
+ }
147
149
return (map[innerObjectName] ? : if (arbitraryInnerNameAllowed) map.keys.firstOrNull()?.let { map[it] }
148
150
? : error(" " ) else error(" " ))
149
151
.apply { initPagingObject(tClazz, this , endpoint) }
@@ -182,14 +184,16 @@ internal inline fun <reified T : Any> String.toCursorBasedPagingObject(
182
184
internal inline fun <reified T > String.toInnerObject (serializer : KSerializer <T >, innerName : String , json : Json ): T {
183
185
val map = this .parseJson {
184
186
val t = (String .serializer() to serializer)
185
- json.parse(MapSerializer (t.first, t.second), this ) }
187
+ json.parse(MapSerializer (t.first, t.second), this )
188
+ }
186
189
return (map[innerName] ? : error(" Inner object with name $innerName doesn't exist in $map " ))
187
190
}
188
191
189
192
internal inline fun <reified T > String.toInnerArray (serializer : KSerializer <List <T >>, innerName : String , json : Json ): List <T > {
190
193
val map = this .parseJson {
191
194
val t = (String .serializer() to serializer)
192
- json.parse(MapSerializer (t.first, t.second), this ) }
195
+ json.parse(MapSerializer (t.first, t.second), this )
196
+ }
193
197
return (map[innerName] ? : error(" Inner object with name $innerName doesn't exist in $map " )).toList()
194
198
}
195
199
0 commit comments