{"id":29801366,"url":"https://github.com/reers/reerjson","last_synced_at":"2026-04-30T02:07:13.960Z","repository":{"id":305436862,"uuid":"1020700180","full_name":"reers/ReerJSON","owner":"reers","description":"A faster version of JSONDecoder and JSONEncoder powered by yyjson","archived":false,"fork":false,"pushed_at":"2026-04-14T19:09:45.000Z","size":2399,"stargazers_count":45,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-14T19:27:25.362Z","etag":null,"topics":["codable","json","jsondecoder","reerjson","yyjson","zippyjson"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE.txt","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-16T09:05:06.000Z","updated_at":"2026-04-14T19:09:55.000Z","dependencies_parsed_at":"2025-08-08T08:19:46.840Z","dependency_job_id":"73fb4e79-d1c1-4b5f-99f7-7003ef2c60bd","html_url":"https://github.com/reers/ReerJSON","commit_stats":null,"previous_names":["reers/reerjson"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/reers/ReerJSON","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reers%2FReerJSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reers%2FReerJSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reers%2FReerJSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reers%2FReerJSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reers","download_url":"https://codeload.github.com/reers/ReerJSON/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reers%2FReerJSON/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31830158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codable","json","jsondecoder","reerjson","yyjson","zippyjson"],"created_at":"2025-07-28T09:45:30.987Z","updated_at":"2026-04-30T02:07:13.941Z","avatar_url":"https://github.com/reers.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReerJSON\n## A faster version of JSONDecoder \u0026 JSONEncoder powered by [yyjson](https://github.com/ibireme/yyjson)\n\n![Coverage: 88%](https://img.shields.io/static/v1?label=coverage\u0026message=88%\u0026color=brightgreen)\n[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible%20%28iOS%29-brightgreen)](https://swift.org/package-manager/)\n\nReerJSON is a really fast JSON parser, and it's inspired by [ZippyJSON](https://github.com/michaeleisel/ZippyJSON) and [Ananda](https://github.com/nixzhu/Ananda).\n\n\u003e **⚠️Important:** When measuring the performance of Swift libraries, make sure you're building in **Release Mode**. \n\u003e When building Swift code on DEBUG compilation, it can be 10-20x slower than equivalent code on RELEASE.\n\n# Benchmarks\n\n## JSONDecoder\n\n### iOS 17+\n\n![CleanShot 2025-09-18 at 14 31 41@2x](https://github.com/user-attachments/assets/2fd6d82b-7a5f-4d6a-a6e5-3b0cd1682acd)\n\n![CleanShot 2025-09-18 at 14 33 30@2x](https://github.com/user-attachments/assets/1cab62ec-077a-4c20-a294-9b5fb01ce5c6)\n\n### Lower than iOS 17\n\n![CleanShot 2025-09-18 at 14 37 04@2x](https://github.com/user-attachments/assets/ed201e1a-c1dc-4ec6-8036-2316bd5bccc4)\n\n### macOS\n\n![CleanShot 2025-09-18 at 13 40 05@2x](https://github.com/user-attachments/assets/3f814fa3-72b0-4005-bea5-7391105aa6dd)\n\n## JSONEncoder\n\n\u003cimg width=\"1233\" height=\"708\" alt=\"ios1\" src=\"https://github.com/user-attachments/assets/1abce9a2-a17b-467d-8edb-6082bc79476b\" /\u003e\n\u003cimg width=\"2474\" height=\"1416\" alt=\"CleanShot 2026-04-15 at 12 43 58@2x\" src=\"https://github.com/user-attachments/assets/f81b77e7-6cb9-4ec1-b11d-9bf5ecfd714e\" /\u003e\n\u003cimg width=\"2464\" height=\"1418\" alt=\"CleanShot 2026-04-15 at 12 46 05@2x\" src=\"https://github.com/user-attachments/assets/57d76606-a76f-453c-a5e0-f0c77ce2872d\" /\u003e\n\n\u003e On older/lower-end chips (e.g. A11), yyjson's \"build DOM tree then serialize\" approach is bottlenecked by smaller caches and weaker branch prediction — exactly the hardware traits yyjson's README states it depends on (\"high instruction level parallelism, excellent branch predictor\"). IkigaJSON's streaming byte-buffer design avoids building an intermediate tree, making it less sensitive to these hardware limitations and thus faster in certain scenarios on constrained processors\n\n### macOS\n\n\u003cimg width=\"1234\" height=\"710\" alt=\"macos\" src=\"https://github.com/user-attachments/assets/3ddf4ff8-fa3a-4cae-ad70-a9653f981acb\" /\u003e\n\n\n\nTested with ReerJSON 1.0.1, ZippyJSON 1.2.15, IkigaJSON 2.3.2\n\n[Code for Benchmarks](https://github.com/Asura19/ReerJSONBenchmark)\n\n# Installation\n\n## Swift Package Manager\n\nAdd dependency in `Package.swift` or project `Package Dependencies`\n```swift\n.package(url: \"https://github.com/reers/ReerJSON.git\", from: \"1.0.2\"),\n```\n\nDepend on `ReerJSON` in your target.\n```swift\n.product(name: \"ReerJSON\", package: \"ReerJSON\" ),\n```\n\n# Usage\n\n## Decoder \u0026\u0026 Encoder\n\n`ReerJSONDecoder` and `ReerJSONEncoder` are API-compatible replacements for Foundation's JSONDecoder and JSONEncoder. \nSimply swap the type and add the import, no other code changes required:\n\n```\nimport ReerJSON\n\n// Before\nlet decoder = JSONDecoder()\nlet encoder = JSONEncoder()\n\n// After\nlet decoder = ReerJSONDecoder()\nlet encoder = ReerJSONEncoder()\n```\n\nAll public interfaces, behaviors, error types, and coding strategies are identical to the Foundation counterparts. The ReerJSON test suite includes exhaustive test cases covering every feature, ensuring full compatibility.\n\n## DOM-Style Access\n\nParse JSON and access values directly without defining types:\n\n```swift\nimport ReerJSON\n\nlet json = #\"{\"users\": [{\"name\": \"Alice\"}, {\"name\": \"Bob\"}]}\"#\nlet value = try JSONValue(string: json)\n\n// Access nested values with subscripts\nif let name = value[\"users\"]?[0]?[\"name\"]?.string {\n    print(name) // \"Alice\"\n}\n```\n\n## In-Place Parsing\n\nFor maximum performance with large JSON files,\nuse in-place parsing to avoid copying the input data:\n\n```swift\nvar data = try Data(contentsOf: fileURL)\nlet json = try JSONValue.parseInPlace(consuming: \u0026data)\n// `data` is now consumed and should not be used\n```\n\nIn-place parsing allows yyjson to parse directly within the input buffer,\navoiding memory allocation for string storage.\nThe `inout` parameter makes it clear that the data is consumed by this operation.\n\n\u003e [!NOTE]\n\u003e For most use cases, the standard `YYJSONValue(data:)` initializer is sufficient.\n\u003e Use in-place parsing only when performance is critical\n\u003e and you can accept the ownership semantics.\n\n## JSONSerialization Alternative\n\nUse `ReerJSONSerialization` with the same API as Foundation's `JSONSerialization`:\n\n```swift\nimport ReerJSON\n\nlet json = #\"{\"message\": \"Hello, World!\"}\"#\nlet data = json.data(using: .utf8)!\n\nlet object = try ReerJSONSerialization.jsonObject(with: data)\nif let dict = object as? [String: Any] {\n    print(dict[\"message\"] as? String ?? \"\") // \"Hello, World!\"\n}\n```\n\nConfigure output formatting with `WritingOptions`:\n\n```swift\n// Pretty printing with 2-space indent (useful for Xcode asset catalogs)\nlet data = try ReerJSONSerialization.data(\n    withJSONObject: dict,\n    options: [.indentationTwoSpaces, .sortedKeys]\n)\n\n// ASCII-only output with trailing newline\nlet data = try ReerJSONSerialization.data(\n    withJSONObject: dict,\n    options: [.escapeUnicode, .newlineAtEnd]\n)\n```\n\n\n# Differences\n\nExcept for the items listed below, ReerJSON behaves exactly the same as Foundation—every capability, every thrown error, and every edge case is covered by a comprehensive test suite.\n\n## Decoder\n\n| Decoder Diff              | Foundation |ReerJSON                   |\n|---------------------------|------------|---------------------------|\n| JSON5                     | ✅         | ✅                        |                       \n| assumesTopLevelDictionary | ✅         | ❌                        |\n| Infinity and NaN          | ±Infinity, ±NaN | ±Infinity, ±NaN, ±Inf and case-insensitive. See [details](https://github.com/reers/ReerJSON/blob/main/Tests/ReerJSONTests/JSONEncoderTests.swift#L1975) |\n\n## Encoder\n\n| Encoder Diff          | Foundation              | ReerJSON                              |\n|-----------------------|-------------------------|---------------------------------------|\n| Unicode escape casing | `\\u001f` (lowercase)    | `\\u001F` (uppercase). Both are valid JSON per RFC 8259 |\n| Pretty-print colon    | `\"key\" : value` (space before and after colon) | `\"key\": value` (space after colon only) |\n\n\n# License\nThis project is licensed under the MIT License.\nPortions of this project incorporate code from the following source code or test code:\n\n* [swiftlang/swift-foundation](https://github.com/swiftlang/swift-foundation), licensed under the Apache License, Version 2.0.\n* [michaeleisel/ZippyJSON](https://github.com/michaeleisel/ZippyJSON), licensed under the MIT License.\n* [mattt/swift-yyjson](https://github.com/mattt/swift-yyjson), licensed under the MIT License. The `ReerJSONSerialization`, `Value`, `Configuration`, `Error`, and `Helpers` modules are adapted from this project.\n\nSee the LICENSE file for the full text of both licenses.\n\n# Acknowledgments\n\nWe would like to express our gratitude to the following projects and their contributors:\n\n* **[ibireme/yyjson](https://github.com/ibireme/yyjson)** - For providing the high-performance JSON parsing library that powers ReerJSON.\n* **[swiftlang/swift-foundation](https://github.com/swiftlang/swift-foundation)** - For implementation reference and comprehensive test suites that helped ensure compatibility.\n* **[michaeleisel/ZippyJSON](https://github.com/michaeleisel/ZippyJSON)** - For the innovative Swift JSON parsing approach and valuable test cases.\n* **[michaeleisel/JJLISO8601DateFormatter](https://github.com/michaeleisel/JJLISO8601DateFormatter)** - For the high-performance date formatting implementation.\n* **[mattt/swift-yyjson](https://github.com/mattt/swift-yyjson)** - For the `JSONSerialization` replacement and DOM-style `JSONValue`/`JSONDocument` APIs. The `ReerJSONSerialization`, `Value`, `Configuration`, `Error`, and `Helpers` source files and their tests are adapted from this project.\n* **[nixzhu/Ananda](https://github.com/nixzhu/Ananda)** - For the pioneering work in integrating yyjson with Swift and providing architectural inspiration.\n\nSpecial thanks to all the open-source contributors who made this project possible.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freers%2Freerjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freers%2Freerjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freers%2Freerjson/lists"}