问题描述
在JavaScript中,可以通过
In JavaScript one can turn a js data structure into a JSON string via
JSON.stringify({somedata: { somesubdata: {}}})
在其他地方,人们可以通过它再次解析为JS数据结构
And somewhere else, one can parse it again into a JS data structure via
var my_obj = JSON.parse("{"somedata":{"some_subdata":{}}}");
对于edn格式,Clojure / ClojureScript中的等价物是什么?
What would be the equivalent in Clojure/ClojureScript for the edn format?
我想在ClojureScript前端字符串化一些数据并在Clojure后端解析它。 (反之亦然)
I want to stringify some data on a ClojureScript front-end and parse it on a Clojure back-end. (and vice versa)
推荐答案
正如评论中指出的那样,可以在引用中找到这个问题的非常详细的答案上面的链接。
As pointed out in a comment, a very detailed answer to this question can be found at the referenced link above.
阅读本文后,快速回答,特别是来自JavaScript的人,可能是:
After reading this, a quick answer, maybe especailly for people coming from JavaScript, would be:
在Clojure中:
parse: clojure.edn/read-string
stringify: prn-str
ClojureScript中的
:
in ClojureScript:
parse: cljs.reader/read-string
stringify: prn-str
这篇关于在clojure / ClojureScript中进行stringify / parse edn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!