【发布时间】:2015-07-26 11:33:59
【问题描述】:
如何在 Clojure 中获取 id 的值?我正在使用 clj-json。
{
"response": {
"users": [
{
"id": "5",
"state": 0
}
]
}
}
【问题讨论】:
如何在 Clojure 中获取 id 的值?我正在使用 clj-json。
{
"response": {
"users": [
{
"id": "5",
"state": 0
}
]
}
}
【问题讨论】:
我在这里假设输入 JSON 在一个名为 input 的字符串变量中:
(require '(clj-json [core :as json]))
(-> (json/parse-string input) (get-in ["response" "users"]) first (get "id"))
=> "5"
【讨论】:
"users"下的值是vector你也可以(get-in json ["response" "users" 0 "id"])