Jsoniter 0.9.8 发布: JSON 性能对标 Protobuf

2017-02-09 09:07:31 +08:00
 taowen

Jsoniter 是一款快且灵活的 JSON 解析器,同时提供 JavaGo 两个版本。

最近发布的 0.9.8 版本对性能对标 Jackson 和 Protobuf 进行了详细的评测: https://github.com/json-iterator/java-benchmark 。性能优化的原理会近期会发布于 infoq 中文站,尽请期待。

同时提供 PHP 一般的体验。在 PHP 里,你只需要记得 json_decode ,什么文档都可以解析。现在在 Java 里,你也可以这么做了。

Any any = Jsoniter.deserialize(input); // deserialize 返回 "Any",实际的解析是延迟在读取时才做的
any.get("items", '*', "name", 0); // 抽取所有 items 的第一个 name
any.get("size").toLong(); // 不管是 "100" 还是 100 ,都给转成 long 类型,就像弱类型一样
any.bindTo(Order.class); // 把 JSON 绑定到对象
for (Any element : any) {} // 遍历集合, Any 实现了 iterable 接口

项目网站: http://jsoniter.com/index.cn.html

3335 次点击
所在节点    分享创造
9 条回复
frazy
2017-02-09 09:31:22 +08:00
支持下~~
mx1700
2017-02-09 09:46:20 +08:00
看起来不错
zachgenius
2017-02-09 09:52:50 +08:00
支持一下
tabris17
2017-02-09 09:56:27 +08:00
横轴是啥?耗时?
EPr2hh6LADQWqRVH
2017-02-09 10:00:18 +08:00
标题党
Protobuf 最大的意义在于传输的时候没有废话
你这个对比不适当,你就对比其他的 json 解析库就完了扯啥 Protobuf
janon
2017-02-09 10:50:22 +08:00
都有 java 版,连跟 gson , fastjson 的对比都木有。。。
agtc
2017-02-09 12:59:07 +08:00
go 和 java 版本的对比呢
Kisesy
2017-02-09 13:33:04 +08:00
..\github.com\json-iterator\go\feature_iter_object.go:31: constant 2166136261 overflows int
..\github.com\json-iterator\go\feature_iter_object.go:60: constant 2166136261 overflows int

go 版, 32 位报错
taowen
2017-02-09 13:34:35 +08:00
@Kisesy 去 github 上报 issue 吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/339162

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX