Skip to content

Instantly share code, notes, and snippets.

@monkeygroover
Last active August 29, 2015 14:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monkeygroover/0e4e2f5648b91c3bc6c4 to your computer and use it in GitHub Desktop.
Save monkeygroover/0e4e2f5648b91c3bc6c4 to your computer and use it in GitHub Desktop.
shapelessspray
import org.ensime.json.FamilyFormats
import spray.json._
object MainApp extends App {
case class Foo(blah: String, blah2: Option[String])
case class Bar(boo: List[Foo])
val wat = Bar(Foo("dfsdf", Some("dsfd")) :: Foo("feefef", None) :: Nil)
import FamilyFormats._
val jsonWat = wat.toJson
println(jsonWat.prettyPrint)
val backAgain = jsonWat.convertTo[Bar]
println(backAgain)
}
@monkeygroover
Copy link
Author

requires: https://github.com/ensime/ensime-server/tree/master/spray-json-shapeless/src/main/scala/org/ensime/json

output:
{
"boo": [{
"blah": "dfsdf",
"blah2": "dsfd"
}, {
"blah": "feefef"
}]
}
Bar(List(Foo(dfsdf,Some(dsfd)), Foo(feefef,None)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment