JSR 275 javax.measure.Dimension string serialization and deserialization

411 Views Asked by At

The JSR of units of measurement 275 and 385 are rejected and not released, yet. However, they're the only sane way to work with units of measurement and dimensions, so I hope to get some insight into the following:

I'd like to serialize and deserialize a javax.measure.Dimension to and from a string to be used in JSON. I don't find any documentation or other information (most articles give an overview of the upcoming features and http://www.unitsofmeasurement.org/ redirects to http://ww17.unitsofmeasurement.org/ which is a blank page). The class names are not very explanatory for me (I searched for parse methods and similar approaches) and I don't find a Dimension class in JSR 385 reference implementation indriya. The only way I see for deserializing is to go through creation of a unit and to parse with AbstractUnit.parse(value).getDimension() which doesn't work the other way around.

The Jackson module jackson-module-unitsofmeasure 1.3.0 only seems to serialize Units.

1

There are 1 best solutions below

0
On

The serialization of a javax.measure.Dimension can be reliably achieved by serializing it's base dimension map which I suggested as pull request to jackson-module-unitsofmeasure at https://github.com/unitsofmeasurement/jackson-module-unitsofmeasure/pull/15.