'How do you ignore fields when serializing a case class using lift-json
I have an example case class Child and I want to serialize it to JSON and print to the screen. This works fine but I don't want to serialize all of the fields, I want to ignore the name field but I can't figure out how. I have tried the following but no luck:
object test extends App{
case class Child(id: Int, name: String, address: String)
val simon = Child(1, "Simon", "Fake street")
implicit val formats: AnyRef with Formats = DefaultFormats + FieldSerializer[Child](ignore("name"))
val output = write(simon)
println(output)
}
The above prints out the whole object but I want to print everything except the name field:
{"id":1,"name":"Simon","address":"Fake street"}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
