BigDecimalAsNumberSerializer
JSON serializer for BigDecimal that preserves numeric precision.
Encodes BigDecimal as an unquoted JSON number literal (not a string), which is important for PostgreSQL's JSONB type to correctly interpret the value as a number rather than text.
Usage Example
@Serializable
@DynamicallyMappable("tribute_amount")
data class TributeAmount(
val province: String,
@Serializable(with = BigDecimalAsNumberSerializer::class)
val amountInDenarii: BigDecimal
)Content copied to clipboard