How to extract from dispatch.json.JsObject

What do I need to do to extract the value for friends_count. I noticed that screen_name is already defined in the Status object and the case class. Js or JsObject extension of different is still required

object TweetDetails extends Js { val friends_count = 'friends_count ? num }

and then the template maps it to every json object in the JsObjects list, as shown below. Symbols confused:

scala> val friends_count = 'friends_count ! num  // I wish SO understood Scala symbols
val twtJsonList = http(Status("username").timeline)
twtJsonList foreach {
      js =>
        val Status.user.screen_name(screen_name) = js
        val Status.text(text) = js
        val friends_counts(friends_count) = js //i cannot figure out how to extract this
        println(friends_count)
        println(screen_name)
        println(text)

}

+5
source share
1 answer

Typically, Scala characters can be thought of as a unique identifier that will always be the same. Each character that is lexically graphically identical refers to the same memory space. There is nothing special about them from the point of view of Scala.

Dispatch-Json , JSON. , , SymOp JsonExtractor.scala.

, , , , :

trait ExtUserProps extends UserProps with Js {
  val friends_count = 'friends_count ! num 
}
object ExtUser extends ExtUserProps with Js

val good_stuff = for {
  item <- http(Status("username").timeline)
  msg = Status.text(item)
  user = Status.user(item)
  screen_name = ExtUser.screen_name(user)
  friend_count = ExtUser.friends_count(user)
} yield (screen_name, msg, friend_count)

, , - UserProps Dispatch-Twitter, friends_count, ExtUser, . ExtUserProps UserProps, Js, sym_add_operators , 'friends_count case SymOp. ! SymOp, Extractor num, Extractor, "friends_count" JSON, . .

- , Twitter JsObjects, , Status.text , , . screen_name friend_count JsObject , , Tuple3 , . [Tuple3 [String, String, BigDecimal]], , .

, . Dispatch , , Scala, - Scala . , , , DSL Scala.

+6

All Articles