King River Lee
09/21/2023, 2:37 AMMap<String, Any?>>
as input json, to get map from req. it parse json number 5 to java.math.BigIntger
rather than <http://kotlin.Int|kotlin.Int>
. any one knows why? or How can I fix it?{"number" : 5}
parse to mapof("number" to 5)
. the 5 in kotlin map is a java.math.BigIntger
Andrew O'Hara
09/21/2023, 3:02 AMKing River Lee
09/21/2023, 3:09 AMs4nchez
09/26/2023, 8:45 AMimport com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.module.kotlin.KotlinModule
import org.http4k.format.ConfigurableJackson
import org.http4k.format.asConfigurable
data class Foo(val bar: Int)
object CustomJackson : ConfigurableJackson(
KotlinModule.Builder().build()
.asConfigurable()
.done()
.configure(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS, false)
)
fun main() {
val jsonExample = """{"bar":123}"""
val foo = CustomJackson.asA<Foo>(jsonExample)
println(foo)
}
Int
rather than BigInteger
😉