{"id":13505044,"url":"https://github.com/orlandos-nl/IkigaJSON","last_synced_at":"2025-03-29T22:31:23.367Z","repository":{"id":43406159,"uuid":"156967903","full_name":"orlandos-nl/IkigaJSON","owner":"orlandos-nl","description":"A high performance JSON library in Swift","archived":false,"fork":false,"pushed_at":"2024-03-20T16:04:48.000Z","size":487,"stargazers_count":373,"open_issues_count":2,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-21T06:07:03.914Z","etag":null,"topics":["codable","decoder","encoder","ios","json","json-inline","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orlandos-nl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"joannis"}},"created_at":"2018-11-10T09:48:09.000Z","updated_at":"2024-05-13T06:31:11.000Z","dependencies_parsed_at":"2023-07-13T16:30:06.554Z","dependency_job_id":"6862b879-0552-4a8c-9da9-f92783dca7d3","html_url":"https://github.com/orlandos-nl/IkigaJSON","commit_stats":{"total_commits":143,"total_committers":6,"mean_commits":"23.833333333333332","dds":0.08391608391608396,"last_synced_commit":"07e5de4f593713333c10ca0f3cb15d67693086de"},"previous_names":["ikiga/ikigajson","autimatisering/ikigajson"],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlandos-nl%2FIkigaJSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlandos-nl%2FIkigaJSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlandos-nl%2FIkigaJSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlandos-nl%2FIkigaJSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orlandos-nl","download_url":"https://codeload.github.com/orlandos-nl/IkigaJSON/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162145,"owners_count":20733357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","decoder","encoder","ios","json","json-inline","swift"],"created_at":"2024-08-01T00:00:57.464Z","updated_at":"2025-03-29T22:31:23.299Z","avatar_url":"https://github.com/orlandos-nl.png","language":"Swift","funding_links":["https://github.com/sponsors/joannis"],"categories":["Packages","Swift"],"sub_categories":["Miscellaneous"],"readme":"\u003ca href=\"https://unbeatable.software\"\u003e\u003cimg src=\"./assets/IkigaJSON.png\" /\u003e\u003c/a\u003e\n\nIkigaJSON is a really fast JSON parser. IkigaJSON is competitive to the modern Foundation JSON in benchmarks, and outperforms older versions of Foundation JSON by a large margin.\n\nAside from being more performant, IkigaJSON has a much lower and more stable memory footprint, too! By design, IkigaJSON scales better than Foundation on larger JSON payloads. All while providing an easy to use API with Codable support.\n\n[Join our Discord](https://discord.gg/H6799jh) for any questions and friendly banter.\n\nPlease note that Swift libraries need to be built in RELEASE compilation mode in order to judge performnce. If you're testing performance on a DEBUG build, you'll find severe mis-optimisations by the compiler that cannot reasonably be fixed in libraries. When building Swift code on DEBUG compilation, it can be 10-20x slower than equivalent code on RELEASE.\n\n### Server-Side Swift\n\nThe above performance statement was tested on Foundation for macOS and iOS. If you're using Swift on Linux with Swift 5.5, your performance is slightly better if you use the new Foundation for Linux. Swift 5.5 does not improve Foundation's JSON performance on macOS or iOS. IkigaJSON performs increasingly better than Linux’ Foundation JSON the bigger your JSON payload gets.\n\n### Adding the dependency\n\nThe 1.x versions are reliant on SwiftNIO 1.x, and for SwiftNIO 2.x support use the 2.x versions of IkigaJSON.\n\n```swift\n// SwiftNIO 1.x\n.package(url: \"https://github.com/orlandos-nl/IkigaJSON.git\", from: \"1.0.0\"),\n// Or, for SwiftNIO 2\n.package(url: \"https://github.com/orlandos-nl/IkigaJSON.git\", from: \"2.0.0\"),\n```\n\n### Usage\n\n```swift\nimport IkigaJSON\n\nstruct User: Codable {\n    let id: Int\n    let name: String\n}\n\nlet data: Data = ...\nvar decoder = IkigaJSONDecoder()\nlet user = try decoder.decode(User.self, from: data)\n```\n\n### In Hummingbird 2\n\nConform Ikiga to Hummingbird's protocols like so:\n\n```swift\nextension IkigaJSONEncoder: HBResponseEncoder {\n    public func encode(_ value: some Encodable, from request: HBRequest, context: some HBBaseRequestContext) throws -\u003e HBResponse {\n        // Capacity should roughly cover the amount of data you regularly expect to encode\n        // However, the buffer will grow if needed\n        var buffer = context.allocator.buffer(capacity: 2048)\n        try self.encodeAndWrite(value, into: \u0026buffer)\n        return HBResponse(\n            status: .ok, \n            headers: [\n                .contentType: \"application/json; charset=utf-8\",\n            ], \n            body: .init(byteBuffer: buffer)\n        )\n    }\n}\n\nextension IkigaJSONDecoder: HBRequestDecoder {\n    public func decode\u003cT\u003e(_ type: T.Type, from request: HBRequest, context: some HBBaseRequestContext) async throws -\u003e T where T : Decodable {\n        let data = try await request.body.collate(maxSize: context.maxUploadSize)\n        return try self.decode(T.self, from: data)\n    }\n}\n```\n\n### In Vapor 4\n\nConform Ikiga to Vapor 4's protocols like so:\n\n```swift\nextension IkigaJSONEncoder: ContentEncoder {\n    public func encode\u003cE: Encodable\u003e(\n        _ encodable: E,\n        to body: inout ByteBuffer,\n        headers: inout HTTPHeaders\n    ) throws {\n        headers.contentType = .json\n        try self.encodeAndWrite(encodable, into: \u0026body)\n    }\n\n    public func encode\u003cE\u003e(_ encodable: E, to body: inout ByteBuffer, headers: inout HTTPHeaders, userInfo: [CodingUserInfoKey : Sendable]) throws where E : Encodable {\n        var encoder = self\n        encoder.userInfo = userInfo\n        headers.contentType = .json\n        try encoder.encodeAndWrite(encodable, into: \u0026body)\n    }\n\n    public func encode\u003cE\u003e(_ encodable: E, to body: inout ByteBuffer, headers: inout HTTPHeaders, userInfo: [CodingUserInfoKey : Any]) throws where E : Encodable {\n        var encoder = self\n        encoder.userInfo = userInfo\n        headers.contentType = .json\n        try encoder.encodeAndWrite(encodable, into: \u0026body)\n    }\n}\n\nextension IkigaJSONDecoder: ContentDecoder {\n    public func decode\u003cD: Decodable\u003e(\n        _ decodable: D.Type,\n        from body: ByteBuffer,\n        headers: HTTPHeaders\n    ) throws -\u003e D {\n        return try self.decode(D.self, from: body)\n    }\n    \n    public func decode\u003cD\u003e(_ decodable: D.Type, from body: ByteBuffer, headers: HTTPHeaders, userInfo: [CodingUserInfoKey : Sendable]) throws -\u003e D where D : Decodable {\n        let decoder = IkigaJSONDecoder(settings: settings)\n        decoder.settings.userInfo = userInfo\n        return try decoder.decode(D.self, from: body)\n    }\n\n    public func decode\u003cD\u003e(_ decodable: D.Type, from body: ByteBuffer, headers: HTTPHeaders, userInfo: [CodingUserInfoKey : Any]) throws -\u003e D where D : Decodable {\n        let decoder = IkigaJSONDecoder(settings: settings)\n        decoder.settings.userInfo = userInfo\n        return try decoder.decode(D.self, from: body)\n    }\n}\n```\n\nRegister the encoder/decoder to Vapor like so:\n\n```swift\nvar decoder = IkigaJSONDecoder()\ndecoder.settings.dateDecodingStrategy = .iso8601\nContentConfiguration.global.use(decoder: decoder, for: .json)\n\nvar encoder = IkigaJSONEncoder()\nencoder.settings.dateEncodingStrategy = .iso8601\nContentConfiguration.global.use(encoder: encoder, for: .json)\n```\n\n### Raw JSON\n\nIkigaJSON supports raw JSON types (JSONObject and JSONArray) like many other libraries do, alongside the codable API described above. The critical difference is that IkigaJSON edits the JSON inline, so there's no additional conversion overhead from Swift type to JSON.\n\n```swift\nvar user = JSONObject()\nuser[\"username\"] = \"Joannis\"\nuser[\"roles\"] = [\"admin\", \"moderator\", \"user\"] as JSONArray\nuser[\"programmer\"] = true\n\nprint(user.string)\n\nprint(user[\"username\"].string)\n// OR\nprint(user[\"username\"] as? String)\n```\n\n### SwiftNIO support\n\nThe encoders and decoders support SwiftNIO.\n\n```swift\nvar user = try JSONObject(buffer: byteBuffer)\nprint(user[\"username\"].string)\n```\n\nWe also have added the ability to use the IkigaJSONEncoder and IkigaJSONDecoder with JSON.\n\n```swift\nlet user = try decoder.decode([User].self, from: byteBuffer)\n```\n\n```swift\nvar buffer: ByteBuffer = ...\n\ntry encoder.encodeAndWrite(user, into: \u0026buffer)\n```\n\nThe above method can be used to stream multiple entities from a source like a database over the socket asynchronously. This can greatly reduce memory usage.\n\n### Performance\n\nBy design you can build on top of any data storage as long as it exposes a pointer API. This way, IkigaJSON doesn't (need to) copy any data from your buffer keeping it lightweight. The entire parser can function with only 1 memory allocation and allows for reusing the Decoder to reuse the memory allocation.\n\nThis allocation (called the JSONDescription) acts as a filter over the original dataset, indicating to IkigaJSON where keys, values and objects start/end. Therefore IkigaJSON can do really fast inline mutations, and provide objects such as JSONObject/JSONDescription that are extremely performant at reading individual values. This also allows IkigaJSON to decode from its own helper types such as JSONObject and JSONArray, since it doesn't need to regenerate a JSONDescription and has the original buffer at hand.\n\n### Support\n\n- All decoding strategies that Foundation supports\n- Unicode\n- Codable\n- Escaping\n- Performance 🚀\n- Date/Data _encoding_ strategies\n- Raw JSON APIs (non-codable)\n- Codable decoding from `JSONObject` and `JSONArray`\n- `\\u` escaped unicode characters\n\n### Media\n\n[Architecture](https://medium.com/@joannis.orlandos/the-road-to-very-fast-json-parsing-in-swift-4a0225c0313c)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forlandos-nl%2FIkigaJSON","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forlandos-nl%2FIkigaJSON","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forlandos-nl%2FIkigaJSON/lists"}