1
我有JSON(例如)提取領域:斯卡拉json4s我如何通過條件
{
"name": "",
"count": 2,
"children": {
"app_open": {
"name": "app_open",
"count": 1,
"children": {
"session_end": {
"name": "session_end",
"count": 1,
"children": {}
}
}
},
"app_install": {
"name": "app_install",
"count": 2,
"children": {
"session_end": {
"name": "session_end",
"count": 2,
"children": {}
}
}
},
"app_instal1l": {
"name": "app_instal1l",
"count": 3,
"children": {
"app_open": {
"name": "app_open",
"count": 3,
"children": {
"session_end": {
"name": "session_end",
"count": 3,
"children": {}
}
}
}
}
}
}
}
我需要提取所有的計數,其中「名」 =「app_open」。
我試圖做到這一點與json4s庫:
val name = jsonInput filterField {
case JField("name", "app_open") => true
case _ => false
}
println("name = " + URL)
我和輸出建議我得帶徒「app_open」的東西,但我得到:
name = List((name,JString(app_open)), (name,JString(session_end)),
(name,JString(app_open)), (name,JString(session_end)))
我」什麼在這裏做錯了嗎? 謝謝!
注意JField是一個類型別名'''(字符串,JValue)'''而且可以在不JField –
嗯匹配,我已經得到了,而編譯沒有錯誤,但您的解決方案正在運行)謝謝! – ANTVirGEO