Closed
Description
I am trying to serialize BigDecimal as json string while avoiding scientific notation (kotlin):
data class Test(
@JsonFormat(shape= JsonFormat.Shape.STRING)
val value: BigDecimal
)
fun main() {
val mapper = jacksonObjectMapper()
.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true)
val test = Test(0.0000000005.toBigDecimal())
println(mapper.writeValueAsString(test))
}
output {"value":"5.0E-10"}
If JsonFormat
is removed, then WRITE_BIGDECIMAL_AS_PLAIN
works and output is {"value":0.00000000050}
(json number, not string), but trying to make it json string with JsonFormat
results in WRITE_BIGDECIMAL_AS_PLAIN
being ignored.
Using latest version, jackson-bom:2.9.8
Metadata
Metadata
Assignees
Labels
No labels