Jackson或JAXB,哪个更适合JSON? [英] Jackson or JAXB, which one is better for JSON?

查看:229
本文介绍了Jackson或JAXB,哪个更适合JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道哪种方法更适合JSON,Jackson或JAXB.我做了一些研究,我知道(也许我错了)我们不应该使用JAXB来转换JSON(某些方案问题),而另一方面JAXB更适合XML.

I wonder which one is better for JSON, Jackson or JAXB. I did some research and I got to know (maybe I'm wrong) that we shouldn't use JAXB to convert JSON(some scheme issue) while on the other hand JAXB is better for XML.

请分享您对此的想法.

推荐答案

在网站上说 JacksonFAQ :

Jackson是"100%JSON",并且不会尝试模仿或模拟XML.属性名称映射基于标准的Java Bean命名约定(尽管可以使用注释或自定义命名策略来覆盖它.)

Jackson is "100% JSON" and does not try to imitate or emulate XML. Property name mapping is based on standard Java Bean naming convention (although can be overridden using annotations or custom naming strategy).

有一些支持兼容性的功能-例如可以选择使用JAXB注释的功能-但从根本上讲,杰克逊是纯JSON/Java数据映射器,并试图最小化JSON和Java数据模型之间的阻抗.

There are some support compatibility features -- such as ability to optionally use JAXB annotations -- but fundamentally Jackson is a pure JSON/Java data mapper and tries to minimize impedance between JSON and Java data models.

它继续 JacksonFaq#JAXB :

Jackson支持与JAXB API(javax.xml.bin)某种程度的互操作性:

Jackson supports some level of interoperability with JAXB API (javax.xml.bin):

在Jackson 1.1中,除了(或代替)核心Jackson注释之外,还可以使用JAXB注释

With Jackson 1.1, it is possible to use JAXB annotations in addition to (or instead of) core Jackson annotations

JAXB API ,代表用于XML绑定的Java体系结构,使用JAXB批注将Java对象与XML文件相互转换

JAXB API, stands for Java Architecture for XML Binding, using JAXB annotation to convert Java object to / from XML file

JAXB捆绑在JDK 1.6及更高版本中,因此无需添加任何其他内容罐子.

JAXB is bundled in JDK 1.6 and above so it's not necessary to add any other jars.

这里有一个测试,说Jackson更快,但我没有检查代码及其结果

Here is a test that says that Jackson is faster but I have not checked the code and its results Test

这篇关于Jackson或JAXB,哪个更适合JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆