I have a property in a case class Foo which I don't want to serialize. However, it's a complicated case class and if possible I'd like to use the automatic Json.writes macro to serialize it. Is it possible to annotate a property in the case class to ensure it is not serialized
case class Foo(
serializeMe: String,
ignoreMe: String
)
val toSerialize = Foo("value1", "Value To Be Ignored")
Json.writes[Foo].writes(toSerialize)
This should serialize to
{
"serializeMe": "value1"
}
I tried:
case class Foo(
serializeMe: String,
@JsonIgnore ignoreMe: String
)
and also
case class Foo(
serializeMe: String,
@JsonProperty(access = Access.WRITE_ONLY) ignoreMe: String
)
None of these seem to be respected by the macro. Any help would be much appreciated