Clojure parse JSON objects and extract specific key -
given have json file contents:
[ { "email": "benb@mit.edu" }, { "email": "aphacker@mit.edu" }, { "email": "eval@mit.edu" }, { "email": "prolog@mit.edu" }, { "email": "bugs@mit.edu" }, { "email": "morebugs@mit.edu" }, { "email": "test@mit.edu" }, { "email": "google@google.com" } ]
how can parse file , value each email
tag need perform operations using values.
example:
retrieve list of emails
(benb@mit.edu, aphacker@mit.edu...)
for each element in list pass value function. understand how pass function, , have come across get-in
function im not sure how use in context.
optionally, if possible wish file stored
benb@mit.edu aphacker@mit.edu ...
which more practical. know how write file , such im not sure how extract email data.
slurp
reads file string, use json parser (e.g. cheshire or data.json) make vector. if want use second file format, look @ line-seq
or split-lines
Comments
Post a Comment