Don't think there is a best practice for your case in particular.

The issue is that js->cli is built on top of protocols to allow converting 
custom JS types to CLJS types. Which makes it extensible for the price of 
checking protocols. In your case you are converting JSON which cannot have 
custom types, so a custom converter only checking for the very few possible 
JSON types would "fix" your problem (and would probably be a lot faster).

The case can be made that cljs-ajax should not be using js->clj when 
converting JSON, maybe even add a json->clj to cljs.core.

The sentinel is the "safest" solution but impacts the performance of 
*everyone*, so we should be doing more benchmarks on more platforms before 
deciding anything. Benchmarks and Votes on the Jira Issue would help to 
push this along.


On Tuesday, October 18, 2016 at 10:21:21 AM UTC+2, John Szakmeister wrote:
> On Tue, Oct 18, 2016 at 2:59 AM, Thomas Heller < 
> <javascript:>> wrote: 
> [snip] 
> > While this issue can be very confusing you will hardly ever run into it 
> when 
> > following best practices. As David suggested using a custom js->clj here 
> > would prevent the issue and is probably the best course of action 
> > regardless. 
> Which best practices?  Is there a good place to read about them?  I've 
> not seen anything that would have steered me away from this problem. 
> In fact, I've seen quite the opposite: js->clj appears to be *the* way 
> to convert from JavaScript data structures to ClojureScript ones. :-( 
> FWIW, I did end up putting something together that was able to do what 
> I needed, but it could have easily gone a different direction. 
> js->clj was being called in a library that I'm using (cljs-ajax), and 
> it, fortunately, had a knob that I could turn to just get the raw json 
> back out without running anything through js->clj.  Had the knob been 
> missing, I think the solution would have been much more painful as I'd 
> either have to fork and maintain a copy of the library, migrate to a 
> different library, or write my own to replace it with. :-( 
> I also like the sentinel idea.  I hope some version of your patch is 
> incorporated. 
> -John 

You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
For more options, visit this group at
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to