Clojure 应用程序数据交换

发布于 2024-08-04 09:01:01 字数 91 浏览 2 评论 0原文

我想在 clojure 应用程序之间来回移动数据。应用程序设置和一些状态信息。

我无法决定使用 xml 还是 s-表达式,您认为每种方法的优缺点是什么?

I would like to move data back and fourth between clojure applications. Application settings and some state information.

I can not decide between using xml or s-expressions, what do you think pros and cons of each approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

德意的啸 2024-08-11 09:01:01

从编程角度来说,最方便的方法是简单地使用文件的打印函数,以及从文件中读取函数。请务必检查一下
print-dup
读取评估
如果你选择这种方法。
优点:简单、容易、人类可读/可编辑。缺点:特定于语言。

Clojure 还有一个内置的 XML 阅读器,因此,如果您需要使数据能够以某种方式与其他 XML 应用程序进行互操作,那么这是一个有效的选择……但我不会推荐 XML,除非您有特定的需要。优点:有时是一个要求。缺点:丑陋、额外工作。

如果您想要 s-exp 的替代品,clojure-contrib 中还有一个很棒的 JSON 库。优点:可互操作。缺点:额外的工作。

以下是关于这些方法的很好的讨论:
http:// groups.google.com/group/clojure/browse_thread/thread/4042e7a087f43c9a/a90b9bc58cc9ec3?q=data+file+group:clojure#0a90b9bc58cc9ec3

Programatically the most convenient way is simply use the print function to a file, and read function from a file. Make sure to check out
print-dup
read-eval
if you choose this approach.
Pros: simple, easy, human readable/editable. Cons: language specific.

Clojure has an inbuilt XML reader also so that is a valid choice if you have a requirement to have the data be interoperable in some way with other XML applications... but I wouldn't recommend XML unless you have a specific need for it. Pros: sometimes a requirement. Cons: ugly, extra work.

There is also a great JSON library in clojure-contrib if you want an alternative to s-exp. Pros: interoperable. Cons: extra work.

Here is a good discussion about these methods:
http://groups.google.com/group/clojure/browse_thread/thread/4042e7a087f43c9a/a90b9bc58cc9ec3?q=data+file+group:clojure#0a90b9bc58cc9ec3

往昔成烟 2024-08-11 09:01:01

如果该文件仅供内部使用(其他程序不需要读取它们),那么它是一个实现细节,请采用最简单的解决方案:s-exprs。
否则,JSON 或 XML。

If this file is for internal use only (no other program will ever need to read them) then it's an implementation detail, go with the simplest solution: s-exprs.
Else, JSON or XML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文