Fork me on GitHub
#planck
<
2017-03-07
>
slipset09:03:31

almost seems (from your, I imagine, way too simple example) that you could stick a set of parens around the string and read it.

slipset09:03:13

as in (clojure.edn/read (make-stream (str “(” the-thing-to-parse “)”)))

slipset09:03:29

where make-stream is left as an exercise for the interested reader.

gamecubate17:03:59

@slipset I guess I like to complicate things. The planck test is however for a larger front-end (web, i.e., CLJS) project. Just needed to do some tests w. planck.

gamecubate17:03:43

New topic. I’ve been given a dataviz project this morning. I need to parse a 15,000,000 row csv file of traffic measurements data and a planck script seems appropriate for the processing/reduction of said data so that it can be mapped affordably (small bandwidth requirements) by client browsers.

gamecubate17:03:26

Hence this quick question: what would you recommend for conversion of clojure structures into json strings?

gamecubate17:03:41

This may seem simple but I have never had to deal with clj->json stuff.

gamecubate17:03:52

So, sorry for what may seem like too simple a question.

gamecubate17:03:06

Googled for it…

org.clojure/data.json
seems good for that.

gamecubate17:03:46

Question: is there an equivalent to “planck -c <jar>” for (planck) shell scripts?

mfikes17:03:26

On macOS, the shabang mechanism lets you add the desired arguments

gamecubate17:03:06

Hmmm, as in

#!/usr/bin/env planck -c some.jar
… I hadn’t thought of that. Thanks @mfikes.

mfikes17:03:24

Yes. I believe this won’t work on Linux.

gamecubate17:03:38

Not working it seems (at least for org.clojure/data.json)...

gamecubate17:03:57

The jar is in my .m2 repository

gamecubate17:03:17

More precisely:

~/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar

mfikes17:03:47

clojure data.json is a Clojure library

gamecubate17:03:22

Yet,

#!/usr/bin/env planck -c "src:~/.m2/repository/org/clojure/data.json/0.2.6/data.json-0.2.6.jar"

(ns process.core
  (:require [planck.core :as core :refer [slurp *command-line-args*]]
                 [org.clojure/data.json :as json]))
reports
No such namespace: org.clojure/data.json, could not locate org/clojure_SLASH_data/json.cljs, org/clojure_SLASH_data/json.cljc, or Closure namespace “data.json”

gamecubate17:03:33

Thought that was the problem.

mfikes17:03:42

Right; it speaks the truth.

gamecubate17:03:52

Need to find a cljs-bootstrapped data -> json lib.

gamecubate17:03:59

Search continues.

gamecubate17:03:32

Almost too simple. What was I thinking?!

(defn ->json [edn]
  (.stringify js/JSON (clj->js edn)))
and
(defn ->edn [json]
  (js->clj (.parse js/JSON json) :keywordize-keys true))