Fork me on GitHub
#clojure-uk
<
2019-12-11
>
dharrigan08:12:06

Good Morning!

dharrigan11:12:58

one forgets at times that the repl is eager...

dharrigan11:12:27

so reading in a 16MB file that is being parsed isn't a great idea (on the repl) 🙂

dharrigan11:12:20

i.e., (json/parsed-seq (io/reader "/home/david/Downloads/a-big-file-of-lovely-json-data.json"))

😱 2
rickmoynihan11:12:55

@dharrigan (set! *print-length* 10) and (set! *print-level* 3) to control depth of traversals

jasonbell11:12:28

perl -i -p -e "s/*//g;" a-big-file-of-lovely-json-data.json 🙂 That’ll fix it for the REPL

jasonbell11:12:16

Or > a-big-file-of-lovely-json-data.json 😉

mccraigmccraig11:12:28

@dharrigan if it makes sense for your use-case, i tend to prefer JSON-lines to vanilla JSON for larger amounts of data

dharrigan11:12:25

I didn't know about the the print-length etc..

mccraigmccraig11:12:55

i always enjoy it when CIDER-repl gets to print out some massive datastructure 😬

jasonbell11:12:47

@mccraigmccraig It’s what the kettle was invented for 🙂

mccraigmccraig11:12:08

i need to grow some extra kidneys to cope

otfrom11:12:24

I find I bump into that problem less often when I use a Rich comment block and c-x c-e and cider-inspect... more often

dharrigan12:12:51

You know if you have a nested map, is there a quick way of evaluating a nested structure in the REPL, similar to let, i.e., in let you can do (let [{{:keys [foo]} :bar} baz] foo) where foo is inside bar, i.e., (def baz {:bar {:foo "wibble"}}) I want to play around with the destructuring on the REPL and I find myself just typing in the entire let form (as previous). Ideally, I would like to do this at the REPL: => {{:keys [foo]} :bar}} and for it to print out wibble

conan14:12:00

i know exactly what you mean and i don't have a way of doing it 😞

Ben Hammond19:12:32

I use (get-in thing [:foo :bar])

Ben Hammond20:12:06

I dislike nested destructuring - it is difficult to re-read

Ben Hammond20:12:14

but I might just be a grump

dharrigan12:12:14

(becomes more relevant for a deeply nested destucturing, playing around at the REPL)

thomas12:12:06

re. large JSON jq is also quite a nice tool when it comes to JSON parsing on the command line.

dharrigan12:12:31

Yes, I use jq a lot, but this is me in the REPL playing around and trying to determine by playing if I've got my let created correctly 🙂

dharrigan12:12:42

I mean, I must invoke jq dozens of times a day 🙂

👍 1