如何從Scala中的Json對象中獲取特定字段?我感覺自己正在圈子裏。在Scala中獲得一個字段json4s
import org.json4s._
import org.json4s.jackson.JsonMethods._
val me = parse(""" {"name":"brian", "state":"frustrated"} """)
現在我想只是狀態。我一直在尋找類似
me("state") -> "frustrated"
我已經試過
me("state")
me.get("state")
me \ "state" <thanks for the idea>
me['state']
me.state
me.NOOOOOOOOOO!!!!!!!
幫助?
你有沒有試過..我「國家」。查看測試規範https://github.com/json4s/json4s/blob/master/tests/src/test/scala/org/json4s/ExtractionExamplesSpec.scala – 2014-12-19 00:04:08
@ m-z修復了錯字,謝謝。 – 2014-12-19 05:09:45