1
我在循環中解析json數據時出現問題。 Iam clojure初學者,需要一些提示來循環瀏覽json數據。通過json數據的clojure循環
的數據是這樣的:
{"photoset" {"primary" "8455893107", "total" "2", "pages" 1, "perpage" 500, "page" 1,
"per_page" 500, "photo"
[{"id" "8455893107", "secret" "1a3236df06", "server" "8087",
"farm" 9, "title" "IMG_0137", "isprimary" "1"}
{"id" "8469482476", "secret" "4c1bf59214",
"server" "8235", "farm" 9, "title" "HippieBus", "isprimary" "0"}]
, "owner"
"[email protected]", "id" "72157632724688181", "ownername" "clojureB5"}, "stat" "ok"}
我想要做的是遍歷兩張照片,並建立與ID和農場價值像http://www.flickr.com/farm/id
了一個新的URL我知道我可以得到這樣一個值:
(-> (get-in (cheshire.core/parse-string (:body picList)) ["photoset" "photo"]) first (get "id"))
但我現在可以通過它循環?
還有一個問題......我想一個函數適用於每一個網址。我試過(doseq [x [links]](println x)),但它將列表作爲一個字符串... – Nico 2013-02-13 18:14:37
明白了:(doseq [e data](prn e)) – Nico 2013-02-13 18:58:06