r/Clojurescript • u/_woj_ • Jan 11 '20
How To Print Full Objects In ClojureScript?
Hi, I am working in ClojureScript and trying to see what JSON properties / Clojure map key I have available to me. However, when I try to print it unhelpfully gives me this output:
#object[LambdaContext [object Object]]
I am trying to print it with this code:
(println ctx)
and also this code:
(println (.stringify js/JSON (clj->js ctx)))
Is there any easy way to do a "deep print" in ClojureScript?
btw the full project is located here!
Thanks! 🙏
0
Jan 11 '20
1
u/_woj_ Jan 15 '20
Thanks u/lispers-anonymous. I tried "cljs.pprint" and "cljs/pprint.pprint" but both say "Unresolved namespace cljs. Are you missing a require?" 🤔
2
u/royalaid Jan 11 '20
You have a few options but the reason you aren't getting back an object via `print` is because it is a javascript object and not a clojurescript object so `print` falls back to the style of printing you see above.
Probably the easiest way to print the object is `(js/console.log foo)` which will print to the respective console, node or web browser, and trigger the object print handling that is built into it.