Given, for example, the following JSON string:
[{"id": "user1", "password": "ps1"},{"id": "user2", "password": "ps2"},{"id": "user3", "password": "ps3"}]
What's the best and most optimized way to parse it in Scala and iterate through every result and analise it properly?
Thank you.
with Lift-JSON:
import net.liftweb.json.JsonParser._
import net.liftweb.json.DefaultFormats
val jsonString = //your jsonString....
case class Credential (id:String, password:String)
implicit val formats = DefaultFormats
val credentials = parse(jsonString).extract[List[Credential]]
credentials foreach { cred => println(cred.id + " " + cred.password) }
everything is explain here : http://www.assembla.com/spaces/liftweb/wiki/JSON_Support
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With