- All Implemented Interfaces and Traits:
- com.fasterxml.jackson.databind.deser.ContextualDeserializer
@CompileStatic
class UomQuantityDeserializer
extends com.fasterxml.jackson.databind.deser.std.StdDeserializer<Quantity>
implements com.fasterxml.jackson.databind.deser.ContextualDeserializer
Jackson deserializer for Quantity from Units of Measurements (UOM) JSR385 API (https://github.com/unitsofmeasurement/unit-api).
Suppose we have the following bean as a target object:
class MyBean {
String name
Quantity<Mass> weight
}
It has a weight
property with typed Quantity
of Mass
(untyped raw quantity is also supported). For this bean, we can provide deserialization string in the following format:
{
"name": "someName",
"weight": {
"value": 5.5
"unitSymbol": "kg"
}
}
The same format is used by the corresponding Quantity serializer - UomQuantitySerializer
.
Any unsupported unit symbol will result in MeasurementParseException
exception. Supported symbols and names are provided by the reference implementation of UOM JSR385
API (https://github.com/unitsofmeasurement/indriya).