C++库json-schema-validator源码分析
最近框架接json schema的需求,因此对其进行了调研
star最多的两个库https://github.com/pboettch/json-schema-validator和https://github.com/danielaparker/jsoncons(已完成)
json-schema-validator | jsoncons | |
---|---|---|
规范支持 | Draft 7 | Draft 7,Draft 2019-09,Draft 2020-12 |
字符串格式检查器 | 没有预设,都要自己实现 | 支持date,email,tcp等常见的数十种 |
外部依赖 | C++11起,依赖github.com/nlohmann/json |
C++20起 |
更新频率 | 253 commits,7 months ago | 12335 commits,yesterday |
总体而言,jsoncons会更好(规范支持全面,功能多,更新频率高),但是接入难度更高(依赖C++20,框架要兼容C++11的钉子户用户)
json-schema-validator基本功能都有,凑活够用,所以还是先接入json-schema-validator,对其进行源码分析