jsoniter-scala
jsoniter-scala copied to clipboard
adtLeafClassNameMapper
The adtLeafClassNameMapper config should take a Class[_] => String. It's both faster as a hashmap lookup, but also clarifies the intent.
Better yet, not sure if possible, it could take the instance itself. I have a use case where I would like to get the name from the instance itself. E.g. Any => String.
adtLeafClassNameMapper is called only in compile time.
What is matter at this time is minimization of c.eval calls that costs too much and can have unwanted side effects or compiler glitches.
There are can be other possibilities to tune bindings in compile time but they need to be discovered and properly tested.
Please see how Chimney library use some kind of DSL on macros to generate case class transformers: https://github.com/scalalandio/chimney
Yeah, I use Chimney. I actually need something like that for computing values. Would that be possible to have something similar?
Another option would be reusing of the @named annotation for ADT classes too.
This should help greatly for local data model but the mapping function fallback is still required if you do not have access to sources of the model to add annotations.