Created
February 3, 2015 09:51
-
-
Save huafengw/306f0250f29b50d154e1 to your computer and use it in GitHub Desktop.
Create a Json from a case class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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