jsoniter-scala icon indicating copy to clipboard operation
jsoniter-scala copied to clipboard

adtLeafClassNameMapper

Open nilskp opened this issue 7 years ago • 4 comments

The adtLeafClassNameMapper config should take a Class[_] => String. It's both faster as a hashmap lookup, but also clarifies the intent.

nilskp avatar Sep 25 '18 16:09 nilskp

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.

nilskp avatar Sep 25 '18 17:09 nilskp

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

plokhotnyuk avatar Sep 26 '18 06:09 plokhotnyuk

Yeah, I use Chimney. I actually need something like that for computing values. Would that be possible to have something similar?

nilskp avatar Sep 26 '18 14:09 nilskp

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.

plokhotnyuk avatar Sep 27 '18 09:09 plokhotnyuk