lundi 28 avril 2014

json4s: Convert type to JValue


Vote count:

0




I have some source object src and would like to get a JValue from it. All the examples and documentation for json4s seem to revolve around getting a JSON-encoded string, like so:



private def encodeJson(src: AnyRef): String = {
import org.json4s.NoTypeHints
import org.json4s.JsonDSL.WithDouble._
import org.json4s.jackson.JsonMethods._
import org.json4s.jackson.Serialization
import org.json4s.jackson.Serialization.write
implicit val formats = Serialization.formats(NoTypeHints)

write(src)
}


It seems like ToJsonWritable[T] is what I want to use, but I can't seem to find an implementation for Writer[AnyRef] (nor can I find scaladocs for json4s which would just tell me the implementations).



asked 53 secs ago






Aucun commentaire:

Enregistrer un commentaire