My problem is I receive an JSON text from say, twitter. Then I want to convert this text to an native object in scala. Is there a standard method to do this? I’m also using Play 2
Here is what I have
import scala.io.Source.{fromInputStream}
import java.net._
val url = new URL("https://api.twitter.com/1/trends/1.json")
val content = fromInputStream( url.openStream ).getLines.mkString("\n")
val json = Json.parse(content)
val a = (json \ "trends" )
Ok(a(0))
I want to get all the trends name from the JSON
I personally prefer
lift-json, but it’s pretty easy to do this with Play’s JSON library:Right now this produces the following:
So yeah, looks about right.