How to easily rename field names in json4s? From their documentation, I tried the following snippet, but it didn't seem to rename the field serialto id.
case class Person(serial: Int, firstName: String)
val rename = FieldSerializer[Person](renameTo("serial", "id"))
implicit val format = DefaultFormats + rename
write(Person(1, "Guest")) //returns {"serial":1,"firstName":"Guest"}
With the Jackson Library, this is pretty easy by annotating. But I'm looking for a clean scala library / solution. Is there a better library or way to serialize an object to json in scala with easy field renaming?
source
share