hershel-theodore-layton/json-post-deserialize
最新稳定版本:v0.2.1
Composer 安装命令:
composer require hershel-theodore-layton/json-post-deserialize
包简介
A fast to run verification to run after json_decode()
README 文档
README
A fast to run verification to run after json_decode()
Why?
\json_decode() can parse invalid JSON. If you want to
store the JSON and expect to be able to parse it in the
future, you should check it is not invalid JSON first.
Future versions of hhvm might not parse invalid JSON
the same way. Other programming environments, like Python,
Go, or JavaScript certainly don't.
How?
After calling \json_decode_with_error(), you should check the
$error variable. If this is null, you might still have
parsed invalid JSON. \HTL\JsonCheck\quick_reject(string $json)
will let you know that this happened. quick_reject() does
not return an error for many invalid JSON documents, but
it does return an error for every invalid JSON document that
gets past \json_decode_with_error().
Why do this in Hack?
There is no function accessible to Hack that can validate
a JSON document. If you want to call a real JSON parser,
you'd need to call an external process. The overhead of
copying the json string to the external process outweighs
the cost of the hot loop in quick_reject().
统计信息
- 总下载量: 127
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-18