とてもよくないので随時更新 よくなっていくはず
https://gist.github.com/astail/0474223cc020a35b4f0edd1d085a2311
[code lang=text] scala> import scala.io.Source import scala.io.Source
scala> import org.json4s. import org.json4s.
scala> import org.json4s.jackson.JsonMethods. import org.json4s.jackson.JsonMethods.
scala> val api = "https://spla2.yuu26.com/regular/now" api: String = https://spla2.yuu26.com/regular/now
scala> val source = Source.fromURL(api, "utf-8") source: scala.io.BufferedSource = non-empty iterator
scala> val str = source.getLines.mkString str: String = {"result":[{"rule":"ナワバリバトル","rule_ex":{"key":"turf_war","name":"ナワバリバトル","statink":""},"maps":["ショッツル鉱山","チョウザメ造船"],"maps_ex":[{"id":17,"name":"ショッツル鉱山","statink":""},{"id":3,"name":"チョウザメ造船","statink":""}],"start":"2018-05-18T17:00:00","start_utc":"2018-05-18T08:00:00+00:00","start_t":1526630400,"end":"2018-05-18T19:00:00","end_utc":"2018-05-18T10:00:00+00:00","end_t":1526637600}]}
scala> val jsonObj = parse(str) jsonObj: org.json4s.JValue = JObject(List*1, (rule_ex,JObject(List*2, (name,JString(ナワバリバトル)), (statink,JString())))), (maps,JArray(List(JString(ショッツル鉱山), JString(チョウザメ造船)))), (maps_ex,JArray(List(JObject(List*3, (name,JString(ショッツル鉱山)), (statink,JString()))), JObject(List*4, (name,JString(チョウザメ造船)), (statink,JString())))))), (start,JString(2018-05-18T17:00:00)), (start_utc,JString(2018-05-18T08:00:00+00:00)), (start_t,JInt(1526630400)), (end,JString(2018-05-18T19:00:00)), (end_utc,JString(2018-05-18T10:00:00+00:00)), (end_t,JInt(1526637600)))))))))
scala> val hogehoge = jsonObj.asInstanceOf[JObject].values hogehoge: scala.collection.immutable.Map[String,Any] = Map(result -> List(Map(maps_ex -> List(Map(id -> 17, name -> ショッツル鉱山, statink -> ""), Map(id -> 3, name -> チョウザメ造船, statink -> "")), start_t -> 1526630400, rule -> ナワバリバトル, end_t -> 1526637600, end_utc -> 2018-05-18T10:00:00+00:00, end -> 2018-05-18T19:00:00, rule_ex -> Map(key -> turf_war, name -> ナワバリバトル, statink -> ""), start_utc -> 2018-05-18T08:00:00+00:00, start -> 2018-05-18T17:00:00, maps -> List(ショッツル鉱山, チョウザメ造船))))
scala> val a = hogehoge("result") a: Any = List(Map(maps_ex -> List(Map(id -> 17, name -> ショッツル鉱山, statink -> ""), Map(id -> 3, name -> チョウザメ造船, statink -> "")), start_t -> 1526630400, rule -> ナワバリバトル, end_t -> 1526637600, end_utc -> 2018-05-18T10:00:00+00:00, end -> 2018-05-18T19:00:00, rule_ex -> Map(key -> turf_war, name -> ナワバリバトル, statink -> ""), start_utc -> 2018-05-18T08:00:00+00:00, start -> 2018-05-18T17:00:00, maps -> List(ショッツル鉱山, チョウザメ造船)))
scala> val b = a.asInstanceOf[List[scala.collection.immutable.Map[String,Any]]] b: List[scala.collection.immutable.Map[String,Any]] = List(Map(maps_ex -> List(Map(id -> 17, name -> ショッツル鉱山, statink -> ""), Map(id -> 3, name -> チョウザメ造船, statink -> "")), start_t -> 1526630400, rule -> ナワバリバトル, end_t -> 1526637600, end_utc -> 2018-05-18T10:00:00+00:00, end -> 2018-05-18T19:00:00, rule_ex -> Map(key -> turf_war, name -> ナワバリバトル, statink -> ""), start_utc -> 2018-05-18T08:00:00+00:00, start -> 2018-05-18T17:00:00, maps -> List(ショッツル鉱山, チョウザメ造船)))
scala> val c = b(0)("maps_ex") c: Any = List(Map(id -> 17, name -> ショッツル鉱山, statink -> ""), Map(id -> 3, name -> チョウザメ造船, statink -> ""))
scala> val d = c.asInstanceOf[List[scala.collection.immutable.Map[String,Any]]] d: List[scala.collection.immutable.Map[String,Any]] = List(Map(id -> 17, name -> ショッツル鉱山, statink -> ""), Map(id -> 3, name -> チョウザメ造船, statink -> ""))
scala> for(xx <- d) println(xx("name")) ショッツル鉱山 チョウザメ造船
scala> source.close [/code]