How to customize Json serialization using Scala and Play Framework?

Posted by Jonas on Stack Overflow See other posts from Stack Overflow or by Jonas
Published on 2011-06-21T14:11:21Z Indexed on 2011/06/21 16:22 UTC
Read the original article Hit count: 245

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?

© Stack Overflow or respective owner

Related posts about JSON

Related posts about scala