Migrating from JSON to EDN

122 views
Skip to first unread message

Jonathon McKitrick

unread,
Sep 4, 2015, 11:28:27 AM9/4/15
to ClojureScript
I have a basic SPA app using JSON for client/server communication. I'm considering switching to EDN.

* Is there any reason I should consider staying with JSON, assuming this API will not be consumed elsewhere?

* How complex is the changeover on both client and server sides?

* Are there any other caveats I might want to consider?

Brandon Adams

unread,
Sep 4, 2015, 12:37:48 PM9/4/15
to clojur...@googlegroups.com
Last time I checked, EDN was slower than JSON browser-side. I don't have any numbers on that, but it never affected the SPA I wrote and used EDN with. It was nice being able to send tagged values and sets, which are both things json doesn't have. 

Have you looked into Transit? It seems to offer a lot of the benefits of EDN without taking much of a performance hit. It's also a little more portable across other languages (although you said this doesn't matter right now).

As far as switching, it's probably just middleware that needs swapping out and your mimetype that needs to change in cljs-http or cljs-ajax. EDN works as a superset of JSON using most of the common ring middleware. If you want to begin taking advantage of EDN features, you won't have to worry about how to map various record types or custom types into JSON anymore (although you obviously have to have a tagged reader implementation registered in the browser to do something with them). 


--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Linus Ericsson

unread,
Sep 4, 2015, 12:54:19 PM9/4/15
to clojur...@googlegroups.com
Transit is noticeably faster than EDN. I cannot recommend to use JSON
between a clojure backend and a clojurescript application, it's just
simply too much work to get everything right, entering dates, big
decimals, UUIDs...

/Linus

jmcki...@gmail.com

unread,
Sep 4, 2015, 1:07:08 PM9/4/15
to clojur...@googlegroups.com
Actually, then, maybe I should check out transit, and modify my questions accordingly.  Would the switch to Transit be similar to the switch to EDN?

You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/bnS4vIUjUu0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.

To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.
--
Jonathon McKitrick

Raymond Huang

unread,
Sep 4, 2015, 3:13:08 PM9/4/15
to clojur...@googlegroups.com

Right, one more thing I've noticed is that you might see quirks with the cljs.reader. Some character literal types are not supported, ie octal (though fairly trivial to patch) and some slight differences such as char literals converted to strings.

Reply all
Reply to author
Forward
0 new messages