dave08
01/31/2018, 5:57 PMval basePriceConverter = object: Converter<Double> {
override fun fromJson(jv: JsonValue) =
if (<http://jv.int|jv.int> != null) {
runBlocking(CommonPool) {
odooClient.read(
"product.product",
listOf(<http://jv.int|jv.int>!!),
listOf("lst_price")
)!!.get(0).get("lst_price") as Double
}
} else {
throw KlaxonException("Couldn't parse product id: ${jv.string}")
}
override fun toJson(o: Double)
= """ { "basePrice" : $o } """
}
val parser = Klaxon().fieldConverter(BasePrice::class, basePriceConverter)
and it works! Thanks for all your help 😄