使用 Ant 解析和编写 JSON
有人设法在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最新版本的 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.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