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.
Usage Example
@Serializable
@DynamicallyMappable("price_data")
data class PriceData(
@Serializable(with = BigDecimalAsNumberSerializer::class)
val price: BigDecimal
)Content copied to clipboard