{"id":20064247,"url":"https://github.com/mochidev/dynamiccodable","last_synced_at":"2026-06-10T15:31:20.183Z","repository":{"id":50133399,"uuid":"358981713","full_name":"mochidev/DynamicCodable","owner":"mochidev","description":"Easily preserve arbitrary Codable data structures when unarchiving","archived":false,"fork":false,"pushed_at":"2021-06-04T04:14:13.000Z","size":33,"stargazers_count":2,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T07:39:52.617Z","etag":null,"topics":["serialization","swift","swift-package-manager","swift-server","swift5-2"],"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/mochidev.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}},"created_at":"2021-04-17T21:02:21.000Z","updated_at":"2021-10-26T18:49:23.000Z","dependencies_parsed_at":"2022-08-19T13:41:02.766Z","dependency_job_id":null,"html_url":"https://github.com/mochidev/DynamicCodable","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochidev%2FDynamicCodable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochidev%2FDynamicCodable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochidev%2FDynamicCodable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mochidev%2FDynamicCodable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mochidev","download_url":"https://codeload.github.com/mochidev/DynamicCodable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241494142,"owners_count":19971870,"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":["serialization","swift","swift-package-manager","swift-server","swift5-2"],"created_at":"2024-11-13T13:45:24.537Z","updated_at":"2026-06-10T15:31:20.151Z","avatar_url":"https://github.com/mochidev.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DynamicCodable\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://swiftpackageindex.com/mochidev/DynamicCodable\"\u003e\n\u003cimg src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmochidev%2FDynamicCodable%2Fbadge%3Ftype%3Dswift-versions\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://swiftpackageindex.com/mochidev/DynamicCodable\"\u003e\n\u003cimg src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmochidev%2FDynamicCodable%2Fbadge%3Ftype%3Dplatforms\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/mochidev/DynamicCodable/actions?query=workflow%3A%22Test+DynamicCodable%22\"\u003e\n\u003cimg src=\"https://github.com/mochidev/DynamicCodable/workflows/Test%20DynamicCodable/badge.svg\" alt=\"Test Status\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n`DynamicCodable` aims to make it easy to preserve arbitrary `Codable` data structures when unarchiving, allowing you to inspect those structures in a type safe way after the decoding is finished.\n\n## Installation\n\nAdd `DynamicCodable` as a dependency in your `Package.swift` file to start using it. Then, add `import DynamicCodable` to any file you wish to use the library in.\n\nPlease check the [releases](https://github.com/mochidev/DynamicCodable/releases) for recommended versions.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/mochidev/DynamicCodable.git\", .upToNextMinor(from: \"1.0.0\")),\n],\n...\ntargets: [\n    .target(\n        name: \"MyPackage\",\n        dependencies: [\n            \"DynamicCodable\",\n        ]\n    )\n]\n```\n\n## What is `DynamicCodable`?\n\n`DynamicCodable` is an enumeration that represents the various primitive types that are themselves codable. Using it is easy — simply mark the portion of your graph as being of type `DynamicCodable` to enable that subtree to be preserved during decoding:\n\n```swift\nstruct ServerResponse: Codable {\n    let status: String\n    let metadata: DynamicCodable\n}\n\nlet response = try JSONDecoder().decode(ServerResponse.self, from: data)\n\n// Consume the metadata whole\nprint(response.metadata)\n\n// Dig into the metadata — it's just an enum!\nswitch response.metadata {\ncase .keyed(let dictionary)\n    print(dictionary[\"debugInfo\"], default: .empty) // Convenience for dictionary[.string(\"debugInfo\"), default: .empty]\ncase .bool(false):\n    print(\"Metadata disabled\")\ncase .nil:\n    print(\"Metadata unavailable\")\ndefault: break\n}\n```\n\nNote that `DynamicCodable` is not limited to be used with JSON coders - it can be used with any `Codable`-compatible coder!\n\n## Contributing\n\nContribution is welcome! Please take a look at the issues already available, or start a new issue to discuss a new feature. Although guarantees can't be made regarding feature requests, PRs that fit with the goals of the project and that have been discussed before hand are more than welcome!\n\nPlease make sure that all submissions have clean commit histories, are well documented, and thoroughly tested. **Please rebase your PR** before submission rather than merge in `main`. Linear histories are required.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmochidev%2Fdynamiccodable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmochidev%2Fdynamiccodable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmochidev%2Fdynamiccodable/lists"}