A faster version of JSONDecoder based on yyjson
ReerJSON is a really fast JSON parser, and it's inspired by ZippyJSON and Ananda.
⚠️ Important: When measuring the performance of Swift libraries, make sure you're building in Release Mode. When building Swift code on DEBUG compilation, it can be 10-20x slower than equivalent code on RELEASE.
Tested with ReerJSON 0.3.0, ZippyJSON 1.2.15, IkigaJSON 2.3.2
Add dependency in Package.swift
or project Package Dependencies
.package(url: "https://github.com/reers/ReerJSON.git", from: "0.3.0"),
Depend on ReerJSON
in your target.
.product(name: "ReerJSON", package: "ReerJSON" ),
Just replace JSONDecoder
with ReerJSONDecoder
wherever you want to use it. So instead of let decoder = JSONDecoder()
, do let decoder = ReerJSONDecoder()
, and everything will just work. This is because ReerJSONDecoder
has the exact same API as JSONDecoder
. Also, don't forget to add import ReerJSON
in files where you use it.
Decoder Diff | Foundation | ReerJSON |
---|---|---|
JSON5 | ✅ | ✅ |
assumesTopLevelDictionary | ✅ | ❌ |
Infinity and NaN | ±Infinity, ±NaN | ±Infinity, ±NaN, ±Inf and case-insensitive. See details |
- Add GitHub workflow for CI.
- Support
CodableWithConfiguration
. - Support JSON5 decoding.
- Implement ReerJSONEncoder.
This project is licensed under the MIT License. Portions of this project incorporate code from the following source code or test code:
- swiftlang/swift-foundation, licensed under the Apache License, Version 2.0.
- michaeleisel/ZippyJSON, licensed under the MIT License.
See the LICENSE file for the full text of both licenses.
We would like to express our gratitude to the following projects and their contributors:
- ibireme/yyjson - For providing the high-performance JSON parsing library that powers ReerJSON.
- swiftlang/swift-foundation - For implementation reference and comprehensive test suites that helped ensure compatibility.
- michaeleisel/ZippyJSON - For the innovative Swift JSON parsing approach and valuable test cases.
- michaeleisel/JJLISO8601DateFormatter - For the high-performance date formatting implementation.
- nixzhu/Ananda - For the pioneering work in integrating yyjson with Swift and providing architectural inspiration.
Special thanks to all the open-source contributors who made this project possible.