How to customize Json serialization using Scala and Play Framework?
- by Jonas
I would like to serialize some Scala case classes to Json. E.g my case class looks like:
case class Item (
id: Int, name: String, price: BigDecimal, created: java.util.Date)
and I would like to serialize it to Json like this:
{"id":3, "name": "apple", "price": 8.00, "created": 123424434}
so I need a custom serilization for BigDecimal and for Date. Where I want the data in milliseconds since 1 jan 1970.
When using Scala and Play Framework, I can return Json using Json(myObject), but how do I customize the serialization? Or is there any recommended Scala library?