使用 Ant 解析和编写 JSON

发布于 2024-12-02 09:24:23 字数 164 浏览 5 评论 0原文

有人设法在 Ant 的任务中解析和编写 JSON 吗?

我需要解析一个 json 文件,修改它,然后将其写回磁盘。我设法使用 JDK 6 中的 rhino 引擎解析它,但我陷入困境,因为我不知道如何将它序列化回磁盘。

看来我需要一个 JSON 序列化器,rhino 显然不包含一个。

Has anyone managed to parse and write JSON in a task in Ant?

I need to parse a json file, modify it and then write it back on disk. I managed to parse it using the rhino engine from JDK 6 but i'm stuck because I don't know how to serialize it back to disk.

It seemes I need a JSON serializer, rhino does not apparently include one.

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

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

发布评论

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

评论(2

惜醉颜 2024-12-09 09:24:23

最新版本的 Rhino 应该有一个 JSON 对象:请参阅这个已解决的 bug 2010 年修复,实际类名为 NativeJSON 并且有一个 stringify 方法应该可以让您检索 JSON 字符串。

Recent versions of Rhino should have a JSON object: see this bug that was resolved as fixed in 2010, and the actual class is called NativeJSON and has a stringify method that should let you retrieve a JSON string.

凉城 2024-12-09 09:24:23

JSON.stringify 作为 ECMAScript 5 工作的一部分在 Rhino 1.7R3 中提供。

请参阅:https://developer.mozilla.org/En/New_in_Rhino_1.7R3

JSON.stringify is available with Rhino 1.7R3 onwards as part of the ECMAScript 5 work.

See: https://developer.mozilla.org/En/New_in_Rhino_1.7R3

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