Skip to content

Instantly share code, notes, and snippets.

@Softsapiens
Forked from aloiscochard/rest-ws-client.scala
Created April 7, 2014 16:36
// Sample usage of ...
// - Dispatch (http://dispatch.databinder.net)
// - SJSON (https://github.com/debasishg/sjson)
// ... to create a basic REST Web Service client for Twitter API
import dispatch._
import scala.reflect.BeanInfo
import sjson.json.Serializer.SJSON
// Model
@BeanInfo class User(val screen_name: String, val description: String) { def this() = this("", "") }
// Http Request
val http = new Http
val json = http(:/("api.twitter.com") / "1/users/show.json" <<? Map("screen_name" -> "aloiscochard") >~ { _.getLines.mkString })
// Deserialization
val user = SJSON.in[User](json)
println(user.description)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment