spring-json 与 jackson for spring 框架 3.0.5
我即将为基于 Spring 的应用程序选择一个 JSON 库,并希望了解这两种解决方案的优缺点。当然,有条件的优点和缺点都是显而易见的:)
提前致谢!
I'm about to choose a JSON library to a spring based application and want to get some pros and cons for both solutions. Of course conditional pros and cons are well seen :)
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果性能很重要,那么在性能方面,Java 平台上没有任何东西可以与 Jackson 相媲美(请参阅此、此 或 这个 作为初始数据点)。
一些较新的库(例如“json-smart”)声称轻量级、快速,但没有外部验证;最常见的是因为他们自己的结果不遵循性能衡量最佳实践 。因此,要了解您的特定用例的性能详细信息,除了进行一些谷歌搜索之外,请使用您自己的数据对其进行测试,看看事情进展如何。
除了性能之外,还有这篇博文(“7 Jackson Killer功能”)概述了 Jackson 必须提供的功能(不考虑与框架的集成)——其他库有自己的优势,并且对于 flex-json 我知道它的输出端(编写JSON)非常灵活和强大。如果您绝对想最小化 JSON 库 (jar) 的大小,"Stringtree" 和 < a href="http://sites.google.com/site/gson/streaming" rel="nofollow">GSON-streaming 是不错的选择(但不提供数据绑定)。
If performance matters, there is nothing on Java platform that comes even close to Jackson with respect to performance (see this, this or this as initial data points).
Some newer libraries (such as "json-smart") claim to be lightweight, fast(er), but have no external verification; most often since their own results do not follow performance measurement best practices. So to know performance details for your specific use case, do test them with your own data and see how things go, in addition to doing bit of googling.
Other than performance, there's this blog post ("7 Jackson killer features") that outlines what Jackson has to offer on its own (not considering integration with frameworks) -- other libraries have their own strengths, and for flex-json I understand its output side (writing JSON) is quite flexible and powerful. And if you absolutely want to minimize JSON library (jar) size, "Stringtree" and GSON-streaming are decent choices (but do not offer data-binding).
关于 Spring-JSON 我不能说太多,但我发现 Jackson 是一个极其成熟和灵活的解决方案。它与 Spring 本身很好地集成;例如,如果您的类路径中有 Jackson,则可以通过 @ResponseBody 注释的方法获得对 JSON 的支持。它相当快,并且有很好的文档。
I can't say much about Spring-JSON, but I've found Jackson to be an extremely mature and flexible solution. It's well integrated with Spring itself; for example, if you have Jackson on the classpath, you get support for JSON with @ResponseBody-annotated methods. It's reasonably fast, and has good documentation.
对于我的项目,Spring 3.0.5 与 Jackson 1.6.3 无缝协作(jackson-core-asl-1.6.3.jar、jackson-mapper-asl-1.6.3.jar)
For my project, Spring 3.0.5 works seamlessly with Jackson 1.6.3 (jackson-core-asl-1.6.3.jar, jackson-mapper-asl-1.6.3.jar)