Reputation: 18005
How do I apply a given function to a JavaScript JSON structure ?
I would like to be able to do the following :
(update-in js-data [.-data] my-fn) ;; fails since .-data is not valid
Upvotes: 0
Views: 428
Reputation: 1915
update-in
and similar functions only work on ClojureScript data structures.
In your specific example you could convert js-data to a ClojureScript data structure like this
(update-in (js->clj js-data) ["data"] my-fn)
If you cannot convert the Javascript object to a plain map you can always modify the original object in-place using set!
.
(set! js-data -data my-fn)
Upvotes: 4