@CompileStatic class UomQuantitySerializer extends com.fasterxml.jackson.databind.ser.std.StdSerializer<Quantity>
Jackson serializer 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 (untyped raw quantities are also supported):class MyBean { String name Quantity<Mass> weight }For the
weight
quantity of 5 kilograms, the bean instance will be serialized as
{ "name": "someName", "weight": { "value": 5, "unitSymbol": "kg" } }Here is another example with temperature quantity:
class MyBeanWithTemperatureQuantity { String name Quantity<Temperature> temperature } MyBeanWithTemperatureQuantity myBeanWithTemperatureQuantity = new MyBeanWithTemperatureQuantity(name: "someName", temperature: 10.degC)will be serialized as
{ "name":"someName", "temperature":{ "value":10, "unitSymbol": "°C" } }
Constructor and description |
---|
UomQuantitySerializer() |