Welcome! Please see the About page for a little more info on how this works.
(def foo (let [bar "baz"] (reify Object))) (.stringify js/JSON (clj->js foo))
Or oneliner:
clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}}' -m cljs.main -re node -e '(def foo (let [bar "baz"] (reify Object))) (.stringify js/JSON (clj->js foo))'
There's bar var value printed which is surprising and may be dangerous if it exposes sensitive data in case of mistake:
bar
"{\"bar\":\"baz\",\"meta529\":{\"meta\":null,\"cnt\":0,\"arr\":[],\"__hash\":-15128758,\"cljs$lang$protocol_mask$partition0$\":16647951,\"cljs$lang$protocol_mask$partition1$\":139268},\"cljs$lang$protocol_mask$partition0$\":393216,\"cljs$lang$protocol_mask$partition1$\":0}"
No bar in the output.
You need to implement toJSON method ` (let [bar "baz"] (reify Object
toJSON
`
(toJSON [this] (js/JSON.stringify #js{:bar bar})))))
This structure printed is just a implementation detail.