typelevel / squants

The Scala API for Quantities, Units of Measure and Dimensional Analysis
https://www.squants.com
Apache License 2.0
922 stars 122 forks source link

JSON Marshalling and Serialization Tests #22

Open garyKeorkunian opened 10 years ago

garyKeorkunian commented 10 years ago

Add tests to ensure that all types support basic JSON marshalling / serialization

This may reveal the need (or desire) to create companion projects for specific JSON frameworks (ie, squants-json4s)

ryan-richt commented 7 years ago

Not sure how you're thinking about this, but in our large project with extensive use of Squants, we have many fields that are the same unit domain type (AreaDensity say) but where we require different fields to be serialized to different specific units (field X to KilogramsPerHectare and field Y to CornBushelsPerAcre, both AreaDensity's). So while normally we'd use a simple scheme to make purely compile time static mapping of types to serializers and we could just derive them all automatically with type classes or macros, instead we have to keep a map per class of which specific unit we want back, meaning we also have to manually specify the serialization methods of the containing class. This is complicated by the fact that units are not subclasses of their domain types. so there are fewer tricks we can play. Not sure if you have a better idea you're thinking of supporting here?