gpt4 book ai didi

json - clojure 从 json 响应中获取数据

转载 作者:行者123 更新时间:2023-12-04 17:10:48 25 4
gpt4 key购买 nike

我有一个 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"}

如何获得不同的值,如 photoset->primary 或 photoset->photo->id ?
我用 (map #(get % "photoset")... 尝试了一些东西但它不起作用。

谢谢!

最佳答案

我认为您正在寻找 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"

关于json - clojure 从 json 响应中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14842551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com