FasterXML / jackson-module-scala

Add-on module for Jackson (https://github.com/FasterXML/jackson) to support Scala-specific datatypes
Apache License 2.0
501 stars 141 forks source link

Examine MixIn annotation support for trait fields #79

Open christophercurrie opened 11 years ago

christophercurrie commented 11 years ago

As discussed in #77, it would be helpful if there were a way to ignore all the implemented fields and methods of a trait used by a class.

gzoller commented 11 years ago

Adding my $0.02. Salat has a very useful ability for traits where it supplies a type hint in the generated JSON when serializing a class for a trait-type. So, for example:

@someAnnotationHere trait X case class Y( val a:String )

case class Target( foo: X ) val t = Target( Y("wow") )

When serializing t you would get something like: {"foo":{"_th":"com.something.Y","a":"wow"}}

The type hint would then be used during deserialization, because of course you'd have no other way to know that the 'X' type is actually a Y and not a Z or something else.