Created
January 4, 2014 14:10
-
-
Save minimal/8255710 to your computer and use it in GitHub Desktop.
Load json from Netflix PigPen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pigpen-exp.core | |
(:require [pigpen.core :as pig] | |
[pigpen.raw :as raw] | |
[clojure.data.json]) | |
(:gen-class)) | |
(defmacro load-json | |
"Loads json data from a file. Each line should contain one value and | |
will be parsed using clojure.data.json/read-str into a value. Keys are | |
converted to keywords. | |
Example: | |
(load-json \"input.json\") | |
See also: pigpen.core/load-clj | |
" | |
[location] | |
`(-> | |
(raw/load$ ~location '~['value] raw/default-storage {:cast "chararray"}) | |
(raw/bind$ '(pigpen.pig/map->bind | |
#(clojure.data.json/read-str % :key-fn clojure.core/keyword)) | |
{:requires '[clojure.data.json], :field-type-in :native}))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment