更快捷式 JSON 序列操作 ffjson

码农软件 · 软件分类 · 性能测试和优化 · 2019-11-26 22:44:35

软件介绍

ffjson 为 Go 结构产生 MarshalJSON 和 UnmarshalJSON 功能。新生成的功能,减轻了进行序列化时对运行反射的依赖,速度比之前更快2至3倍。在 ffjson 不能识别涉及类型的情况下,它会回退到  encoding/json,这意味着 ffjson 是安全替代原件。通过使用 ffjson,您的 JSON 序列化只会越来越快,因为没有额外代码更改。

当你改变 struct 时,你需要重新运行 ffjson (或将它作为编译工具的一部分)。

入门:

如果 myfile.go 包含结构类型,你想要更快,假设 GOPATH 被设置为现有项目(这意味着在这个特殊的例子,如果 myfile.go 是在 MyProject 目录的一个合理值,该项应在$GOPATH/src/myproject),你可以运行:

go get -u github.com/pquerna/ffjson
ffjson myfile.go
git add myfile_ffjson.go

性能:

  • MarshalJSON is 2x to 3x faster than encoding/json.

  • UnmarshalJSON is 2x to 3x faster than encoding/json.

特点:

  • 支持解组(Unmarshal Support):从 v0.9版本之后,开始支持散集结构。

  • 直接替代原件(Drop in Replacement):因 ffjson 执行的接口已被 encoding/json 定义,用户使用的性能增强。

  • 支持所有类型:ffjson 适用于大多数 Go 的类型——有任何类型路径不支持的话,他将自动会退到 encoding/json,这意味着所有的工作都要在 box 外工作,如果不是,打开一个issue 。

  • ffjson 跳跃:如果你想 ffjson 忽略一个结构,添加 ffjson ,跳过你想忽略的部分,然后重新串连。

  • 拓展测试:包含广泛的测试套件,适合与 JSON parser 相对的模糊测试。

本文地址:https://codercto.com/soft/d/19871.html

Twenty Lectures on Algorithmic Game Theory

Twenty Lectures on Algorithmic Game Theory

Tim Roughgarden / Cambridge University Press / 2016-8-31 / USD 34.99

Computer science and economics have engaged in a lively interaction over the past fifteen years, resulting in the new field of algorithmic game theory. Many problems that are central to modern compute......一起来看看 《Twenty Lectures on Algorithmic Game Theory》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具