Is there an easy way to serialize to json without "tpe" field inside an object? I need to serialize case classes to json structures and then, send them over the wire (They won't been deserialized in future). I have a specific api, so.. I don't need additional fields.
For class Person illustrated below:
case class Person(Name: String, Age: int, CandyLover: Boolean)
I'd like to see following:
{
"Name": "Paul",
"Age": 23,
"CandyLover": true
}
Probably the simplest way to do it is to pass somehow the
HintintoJSONPickleBuilder. Quick way to do it is to override builders inJSONPickleFormatby callinghintStaticallyElidedType()method fromPickleTools.Here is kind of code snippet to demonstrate it:
The output of
println(pickledPersonObject.value)will be as you need:This way you will stay aligned with further pickle updates.
P.S. If someone knows more elegant and convenient way to reach the same behaviour - please let us know :-)