Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 10 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Opinion-based Update the question so it can be answered with facts and citations by editing this post.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
我上周做了这项研究,最终得到了两个相同的库。当我使用 Spring 3 (在其默认 Json 视图中采用 Jackson 'JacksonJsonView') 对我来说这样做更自然。这两个库几乎是相同的......最后它们只是映射到一个 json 文件! :)
不管怎样,正如你所说,杰克逊的表现有+,这对我来说非常重要。该项目也非常活跃,您可以从他们的网页中看到,这也是一个非常好的迹象。
I did this research the last week and I ended up with the same 2 libraries. As I'm using Spring 3 (that adopts Jackson in its default Json view 'JacksonJsonView') it was more natural for me to do the same. The 2 lib are pretty much the same... at the end they simply map to a json file! :)
Anyway as you said Jackson has a + in performance and that's very important for me. The project is also quite active as you can see from their web page and that's a very good sign as well.
Jackson 和 Gson 是关于实际数据绑定支持的最完整的 Java JSON 包;许多其他包仅提供原始映射/列表(或等效的树模型)绑定。
两者都完全支持泛型类型,并且为许多常见用例提供了足够的可配置性。
由于我对 Jackson 比较熟悉,所以我认为 Jackson 在以下几个方面比 Gson 有更完整的支持(如果我错过了 Gson 功能,请原谅):
Jackson and Gson are the most complete Java JSON packages regarding actual data binding support; many other packages only provide primitive Map/List (or equivalent tree model) binding.
Both have complete support for generic types, as well, as enough configurability for many common use cases.
Since I am more familiar with Jackson, here are some aspects where I think Jackson has more complete support than Gson (apologies if I miss a Gson feature):
Gson 1.6 现在包含一个低级流 API 和一个新的解析器,实际上比 Jackson 更快。
Gson 1.6 now includes a low-level streaming API and a new parser which is actually faster than Jackson.
添加到上面已经给出的其他答案。如果不区分大小写对您来说很重要,那么请使用 Jackson。 Gson 不支持键名称不区分大小写,而 jackson 则支持。
这里有两个相关链接
(否)Gson 中的区分大小写支持:
GSON:如何从 Json 获取不区分大小写的元素?
杰克逊支持区分大小写
https://gist.github.com/electrum/1260489
Adding to other answers already given above. If case insensivity is of any importance to you, then use Jackson. Gson does not support case insensitivity for key names, while jackson does.
Here are two related links
(No) Case sensitivity support in Gson :
GSON: How to get a case insensitive element from Json?
Case sensitivity support in Jackson
https://gist.github.com/electrum/1260489
看来GSon不支持JAXB。
通过使用 JAXB 带注释的类来创建或处理 JSON 消息,我可以共享同一个类来使用 Spring MVC 创建 Restful Web Service 接口。
It seems that GSon don't support JAXB.
By using JAXB annotated class to create or process the JSON message, I can share the same class to create the Restful Web Service interface by using spring MVC.