{"id":18482951,"url":"https://github.com/denismurphy/dictionary-codable","last_synced_at":"2025-04-08T18:32:05.833Z","repository":{"id":190055944,"uuid":"587342019","full_name":"denismurphy/dictionary-codable","owner":"denismurphy","description":"Lightweight utility for encoding and decoding Swift objects to and from dictionaries","archived":false,"fork":false,"pushed_at":"2024-08-18T17:05:20.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T20:06:15.844Z","etag":null,"topics":["codable","dictionary","ios","ipados","macos","poso","serialization","swift","watchos"],"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/denismurphy.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}},"created_at":"2023-01-10T14:30:05.000Z","updated_at":"2024-10-22T14:29:24.000Z","dependencies_parsed_at":"2024-08-18T18:25:25.676Z","dependency_job_id":"81ea65ce-8796-48a3-8214-aea599d7bf6f","html_url":"https://github.com/denismurphy/dictionary-codable","commit_stats":null,"previous_names":["denismurphy/dictionary-codable"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denismurphy%2Fdictionary-codable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denismurphy%2Fdictionary-codable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denismurphy%2Fdictionary-codable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denismurphy%2Fdictionary-codable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denismurphy","download_url":"https://codeload.github.com/denismurphy/dictionary-codable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247902323,"owners_count":21015430,"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","dictionary","ios","ipados","macos","poso","serialization","swift","watchos"],"created_at":"2024-11-06T12:32:24.900Z","updated_at":"2025-04-08T18:32:00.824Z","avatar_url":"https://github.com/denismurphy.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📚 Dictionary Codable\n\nThe `DictionaryCodable` library is a lightweight utility for encoding and decoding Swift objects to and from dictionaries. 🔄 This library provides a simple way to convert your Swift objects to dictionaries and vice versa.\n\n## 🚀 Usage\n\n### 🔒 Encoding\n\nThe `DictionaryEncoder` class offers a straightforward way to encode Swift objects to dictionaries. Here's an example:\n\n```swift\nstruct Person: Encodable {\n    let name: String\n    let age: Int\n}\n\nlet person = Person(name: \"John Doe\", age: 30)\nlet encoder = DictionaryEncoder()\nlet dictionary = try encoder.encode(person)\nprint(dictionary) // prints [\"name\": \"John Doe\", \"age\": 30]\n```\n\nYou can also encode an array of Swift objects:\n\n```swift\nlet people = [Person(name: \"John Doe\", age: 30), Person(name: \"Jane Doe\", age: 25)]\nlet encoder = DictionaryEncoder()\nlet dictionaryArray = try encoder.encode(people)\nprint(dictionaryArray) // prints [[\"name\": \"John Doe\", \"age\": 30], [\"name\": \"Jane Doe\", \"age\": 25]]\n```\n\n### 🔓 Decoding\n\nUse the `DictionaryDecoder` class to decode a dictionary into a Swift object:\n\n```swift\nstruct Person: Decodable {\n    let name: String\n    let age: Int\n}\n\nlet dictionary = [\"name\": \"John Doe\", \"age\": 30]\nlet decoder = DictionaryDecoder()\nlet person = try decoder.decode(Person.self, from: dictionary)\nprint(person) // prints \"Person(name: \"John Doe\", age: 30)\"\n```\n\nYou can also decode an array of dictionaries into an array of Swift objects:\n\n```swift\nlet dictionaryArray = [[\"name\": \"John Doe\", \"age\": 30], [\"name\": \"Jane Doe\", \"age\": 25]]\nlet decoder = DictionaryDecoder()\nlet people = try decoder.decode([Person].self, from: dictionaryArray)\nprint(people) // prints \"[Person(name: \"John Doe\", age: 30), Person(name: \"Jane Doe\", age: 25)]\"\n```\n\n## ⚠️ Note\n\nThis encoder/decoder implementation is simple and straightforward. It does not support nested or complex object structures.\n\n## 📄 License\n\nThis code is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenismurphy%2Fdictionary-codable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenismurphy%2Fdictionary-codable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenismurphy%2Fdictionary-codable/lists"}