Skip to content

Instantly share code, notes, and snippets.

@debasishg
Created July 26, 2010 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debasishg/491021 to your computer and use it in GitHub Desktop.
Save debasishg/491021 to your computer and use it in GitHub Desktop.
case class Holder(item: List[String])
implicit val HolderFormat: Format[Holder] = wrap[Holder, List[String]]("item")(_.item, Holder)
// instantiate the case class
val n = Holder(List("debasish ghosh", "jonas boner", "stephan schmidt"))
// js is a JsValue
val js = tojson(n)
// convert js to string and print
println(dispatch.json.JsValue.toJson(js))
// de-serailzing using fromjson will give back the Holder n
fromjson[Holder](tojson(n)) should equal(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment