Skip to content

Instantly share code, notes, and snippets.

@josep2
Last active December 31, 2016 06:13
Show Gist options
  • Save josep2/86e4e400c6ca16c98e51038c43421b28 to your computer and use it in GitHub Desktop.
Save josep2/86e4e400c6ca16c98e51038c43421b28 to your computer and use it in GitHub Desktop.
import spray.json._
val myJson: String = "{
color: "red",
value: "#f00"
}" // JSON defined above
case class Settings(color: String, value: String) // Case class for the JSON
object SettingsProtocol extends DefaultJsonProtocol {
implicit val settingsFormat = jsonFormat2(Settings)
}
import SettingsProtocol._
Json.parse(myJson).convertTo[Settings]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment