Skip to content

Instantly share code, notes, and snippets.

@huafengw
Created February 3, 2015 09:51
Show Gist options
  • Save huafengw/306f0250f29b50d154e1 to your computer and use it in GitHub Desktop.
Save huafengw/306f0250f29b50d154e1 to your computer and use it in GitHub Desktop.
Create a Json from a case class
import spray.json._
import DefaultJsonProtocol._
case class Person(id: Int, name: String)
object Test extends App{
implicit val personFormat = jsonFormat2(Person.apply)
val person = Person(1, "Tom").toJson
println(person.prettyPrint)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment