muster icon indicating copy to clipboard operation
muster copied to clipboard

Support renaming fields

Open casualjim opened this issue 11 years ago • 4 comments

Currently there is no way to override field names.

Should this be implemented with an implicit context or through annotations that look the same as the ones in Jackson and JAXB

casualjim avatar Jun 01 '14 17:06 casualjim

I'm not sure if this solution based on annotation is a good idea - what in case when we would like to serialize an object of 3rd party class?

mkubala avatar Jun 05 '14 07:06 mkubala

you raise a very good point. So we should provide a type of implicit formats but that works with macros?

casualjim avatar Jun 05 '14 07:06 casualjim

I haven't any experience with macros yet. But because implicits are resolved also at compile time, typeclasses may work..

We need to verify such possibility.

mkubala avatar Jun 05 '14 07:06 mkubala

I've got quite a bit working with macros. but things like typehints, renaming fields etc not yet. We can resolve implicits at compile time with macros, like here: https://github.com/json4s/muster/blob/master/core/src/main/scala/muster/consumer.scala#L197

This already leverages the type class pattern for doing it. What I'm proposing here is extra stuff to not have to write a full custom serializer (typeclass) but instead get some of those convenience things in another type of context object or something. Maybe it's too much I don't really know :)

casualjim avatar Jun 05 '14 07:06 casualjim