Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Forked from seanparsons/gist:4453577
Created January 5, 2013 02:55
Show Gist options
  • Save markhibberd/4459399 to your computer and use it in GitHub Desktop.
Save markhibberd/4459399 to your computer and use it in GitHub Desktop.
case class Person(name: String, age: Int)
implicit val DecodePerson: DecodeJson[Person] = jdecode2L(Person(_: String, _: Int))("name", "age")
implicit val EncodePerson: EncodeJson[Person] = jencode2L((p: Person) => (p.name, p.age))("name", "age")
val decoded: Option[Person] = """{"name":"Fred","age":"40"}""".decodeOption[Person]
val encoded: Option[String] = decoded.map(_.jencode.nospaces)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment