[英]clojure get data out of json response
I have an json response and would like to get the values out: 我有一个json响应,并希望得到值:
(cheshire.core/parse-string (:body picList))
{"photoset" {"primary" "8455893107", "total" "1", "pages" 1, "perpage" 500, "page" 1,
"per_page" 500, "photo" [{"id" "8455893107", "secret" "1a3236df06", "server" "8087",
"farm" 9, "title" "IMG_0137", "isprimary" "1"}], "owner" "93029076@N07", "id"
"72157632724688181", "ownername" "clojureB5"}, "stat" "ok"}
How can I get the different values like photoset->primary or photoset->photo->id ? 如何获得不同的值,如photoset-> primary或photoset-> photo-> id? I tried something with (map #(get % "photoset")...
but it doest work. 我尝试了一些东西(map #(get % "photoset")...
但它确实有效。
Thanks! 谢谢!
I think you're looking for clojure.core/get-in 我想你正在寻找clojure.core / get-in
(get-in your-parsed-json ["photoset" "primary"]) ;; "8455893107"
(-> (get-in your-parsed-json ["photoset" "photo"])
first
(get "id")) ;; "8455893107"
(get-in your-parsed-json ["photoset" "photo" 0 "id"]) ;; "8455893107"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.