V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
taowen
V2EX  ›  分享创造

Jsoniter 0.9.8 发布: JSON 性能对标 Protobuf

  •  
  •   taowen · 2017-02-09 09:07:31 +08:00 · 3302 次点击
    这是一个创建于 2604 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    protobuf-vs-jsoniter

    同时提供 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

    9 条回复    2017-02-09 13:34:35 +08:00
    frazy
        1
    frazy  
       2017-02-09 09:31:22 +08:00
    支持下~~
    mx1700
        2
    mx1700  
       2017-02-09 09:46:20 +08:00 via Android
    看起来不错
    zachgenius
        3
    zachgenius  
       2017-02-09 09:52:50 +08:00
    支持一下
    tabris17
        4
    tabris17  
       2017-02-09 09:56:27 +08:00
    横轴是啥?耗时?
    EPr2hh6LADQWqRVH
        5
    EPr2hh6LADQWqRVH  
       2017-02-09 10:00:18 +08:00   ❤️ 2
    标题党
    Protobuf 最大的意义在于传输的时候没有废话
    你这个对比不适当,你就对比其他的 json 解析库就完了扯啥 Protobuf
    janon
        6
    janon  
       2017-02-09 10:50:22 +08:00
    都有 java 版,连跟 gson , fastjson 的对比都木有。。。
    agtc
        7
    agtc  
       2017-02-09 12:59:07 +08:00
    go 和 java 版本的对比呢
    Kisesy
        8
    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
        9
    taowen  
    OP
       2017-02-09 13:34:35 +08:00
    @Kisesy 去 github 上报 issue 吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3005 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 14:41 · PVG 22:41 · LAX 07:41 · JFK 10:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.