@@ -206,6 +206,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
206
206
Byte ::class -> convert<Number > { it.toByte() }
207
207
Short ::class -> convert<Number > { it.toShort() }
208
208
Long ::class -> convert<Number > { it.toLong() }
209
+ Boolean ::class -> convert<Number > { it != 0 }
209
210
else -> null
210
211
}
211
212
Int ::class -> when (toClass) {
@@ -215,6 +216,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
215
216
Short ::class -> convert<Int > { it.toShort() }
216
217
Long ::class -> convert<Int > { it.toLong() }
217
218
BigDecimal ::class -> convert<Int > { it.toBigDecimal() }
219
+ Boolean ::class -> convert<Int > { it != 0 }
218
220
LocalDateTime ::class -> convert<Int > { it.toLong().toLocalDateTime(defaultTimeZone) }
219
221
LocalDate ::class -> convert<Int > { it.toLong().toLocalDate(defaultTimeZone) }
220
222
java.time.LocalDateTime ::class -> convert<Long > { it.toLocalDateTime(defaultTimeZone).toJavaLocalDateTime() }
@@ -228,6 +230,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
228
230
Long ::class -> convert<Double > { it.roundToLong() }
229
231
Short ::class -> convert<Double > { it.roundToInt().toShort() }
230
232
BigDecimal ::class -> convert<Double > { it.toBigDecimal() }
233
+ Boolean ::class -> convert<Double > { it != 0.0 }
231
234
else -> null
232
235
}
233
236
Long ::class -> when (toClass) {
@@ -237,6 +240,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
237
240
Short ::class -> convert<Long > { it.toShort() }
238
241
Int ::class -> convert<Long > { it.toInt() }
239
242
BigDecimal ::class -> convert<Long > { it.toBigDecimal() }
243
+ Boolean ::class -> convert<Long > { it != 0L }
240
244
LocalDateTime ::class -> convert<Long > { it.toLocalDateTime(defaultTimeZone) }
241
245
LocalDate ::class -> convert<Long > { it.toLocalDate(defaultTimeZone) }
242
246
Instant ::class -> convert<Long > { Instant .fromEpochMilliseconds(it) }
@@ -271,13 +275,15 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
271
275
Int ::class -> convert<Float > { it.roundToInt() }
272
276
Short ::class -> convert<Float > { it.roundToInt().toShort() }
273
277
BigDecimal ::class -> convert<Float > { it.toBigDecimal() }
278
+ Boolean ::class -> convert<Float > { it != 0.0F }
274
279
else -> null
275
280
}
276
281
BigDecimal ::class -> when (toClass) {
277
282
Double ::class -> convert<BigDecimal > { it.toDouble() }
278
283
Int ::class -> convert<BigDecimal > { it.toInt() }
279
284
Float ::class -> convert<BigDecimal > { it.toFloat() }
280
285
Long ::class -> convert<BigDecimal > { it.toLong() }
286
+ Boolean ::class -> convert<BigDecimal > { it != BigDecimal .ZERO }
281
287
else -> null
282
288
}
283
289
LocalDateTime ::class -> when (toClass) {
@@ -286,6 +292,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
286
292
Long ::class -> convert<LocalDateTime > { it.toInstant(defaultTimeZone).toEpochMilliseconds() }
287
293
java.time.LocalDateTime ::class -> convert<LocalDateTime > { it.toJavaLocalDateTime() }
288
294
java.time.LocalDate ::class -> convert<LocalDateTime > { it.date.toJavaLocalDate() }
295
+ java.time.LocalTime ::class -> convert<LocalDateTime > { it.toJavaLocalDateTime().toLocalTime() }
289
296
else -> null
290
297
}
291
298
java.time.LocalDateTime ::class -> when (toClass) {
@@ -294,6 +301,7 @@ internal fun createConverter(from: KType, to: KType, options: ParserOptions? = n
294
301
Instant ::class -> convert< java.time.LocalDateTime > { it.toKotlinLocalDateTime().toInstant(defaultTimeZone) }
295
302
Long ::class -> convert< java.time.LocalDateTime > { it.toKotlinLocalDateTime().toInstant(defaultTimeZone).toEpochMilliseconds() }
296
303
java.time.LocalDate ::class -> convert< java.time.LocalDateTime > { it.toLocalDate() }
304
+ java.time.LocalTime ::class -> convert< java.time.LocalDateTime > { it.toLocalTime() }
297
305
else -> null
298
306
}
299
307
LocalDate ::class -> when (toClass) {
0 commit comments