{"id":1850,"url":"https://github.com/Zewo/Reflection","last_synced_at":"2025-08-02T05:32:52.809Z","repository":{"id":56921723,"uuid":"57980660","full_name":"Zewo/Reflection","owner":"Zewo","description":"DEPRECATED","archived":false,"fork":false,"pushed_at":"2021-03-29T19:01:30.000Z","size":103,"stargazers_count":599,"open_issues_count":9,"forks_count":46,"subscribers_count":37,"default_branch":"master","last_synced_at":"2024-12-04T10:06:52.772Z","etag":null,"topics":["dynamic","introspection","ios","linux","mirroring","reflection","runtime","server","server-side-swift","swift","swiftpm"],"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/Zewo.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":"2016-05-03T15:37:57.000Z","updated_at":"2024-07-18T07:24:55.000Z","dependencies_parsed_at":"2022-08-20T22:20:21.472Z","dependency_job_id":null,"html_url":"https://github.com/Zewo/Reflection","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zewo%2FReflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zewo%2FReflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zewo%2FReflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zewo%2FReflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zewo","download_url":"https://codeload.github.com/Zewo/Reflection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228088846,"owners_count":17867481,"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":["dynamic","introspection","ios","linux","mirroring","reflection","runtime","server","server-side-swift","swift","swiftpm"],"created_at":"2024-01-05T20:15:57.272Z","updated_at":"2024-12-06T09:30:26.152Z","avatar_url":"https://github.com/Zewo.png","language":"Swift","readme":"# Reflection [DEPRECATED]\n\n[![Swift][swift-badge]][swift-url]\n[![License][mit-badge]][mit-url]\n[![Slack][slack-badge]][slack-url]\n[![Travis][travis-badge]][travis-url]\n[![Codecov][codecov-badge]][codecov-url]\n[![Codebeat][codebeat-badge]][codebeat-url]\n\n**Reflection** provides an API for advanced reflection at runtime including dynamic construction of types.\n\n## Usage\n\n```swift\nimport Reflection\n\nstruct Person {\n  var firstName: String\n  var lastName: String\n  var age: Int\n}\n\n// Reflects the instance properties of type `Person`\nlet props = try properties(Person.self)\n\nvar person = Person(firstName: \"John\", lastName: \"Smith\", age: 35)\n\n// Retrieves the value of `person.firstName`\nlet firstName: String = try get(\"firstName\", from: person)\n\n// Sets the value of `person.age`\ntry set(36, key: \"age\", for: \u0026person)\n\n// Creates a `Person` from a dictionary\nlet friend: Person = try construct(dictionary: [\"firstName\" : \"Sarah\",\n                                                \"lastName\" : \"Gates\",\n                                                \"age\" : 28])\n\n\n```\n\n## Installation\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    dependencies: [\n        .Package(url: \"https://github.com/Zewo/Reflection.git\", majorVersion: 0, minor: 15),\n    ]\n)\n```\n\n## Advanced Usage\n\n```swift\n// `Reflection` can be extended for higher-level packages to do mapping and serializing.\n// Here is a simple `Mappable` protocol that allows deserializing of arbitrary nested structures.\n\nimport Reflection\n\ntypealias MappableDictionary = [String : Any]\n\nenum Error : ErrorProtocol {\n    case missingRequiredValue(key: String)\n}\n\nprotocol Mappable {\n    init(dictionary: MappableDictionary) throws\n}\n\nextension Mappable {\n\n    init(dictionary: MappableDictionary) throws {\n        self = try construct { property in\n            if let value = dictionary[property.key] {\n                if let type = property.type as? Mappable.Type, let value = value as? MappableDictionary {\n                    return try type.init(dictionary: value)\n                } else {\n                    return value\n                }\n            } else {\n                throw Error.missingRequiredValue(key: property.key)\n            }\n        }\n    }\n\n}\n\nstruct Person : Mappable {\n    var firstName: String\n    var lastName: String\n    var age: Int\n    var phoneNumber: PhoneNumber\n}\n\nstruct PhoneNumber : Mappable {\n    var number: String\n    var type: String\n}\n\nlet dictionary = [\n    \"firstName\" : \"Jane\",\n    \"lastName\" : \"Miller\",\n    \"age\" : 54,\n    \"phoneNumber\" : [\n        \"number\" : \"924-555-0294\",\n        \"type\" : \"work\"\n    ] as MappableDictionary\n] as MappableDictionary\n\nlet person = try Person(dictionary: dictionary)\n\n```\n\n## Support\n\nIf you need any help you can join our [Slack](http://slack.zewo.io) and go to the **#help** channel. Or you can create a Github [issue](https://github.com/Zewo/Zewo/issues/new) in our main repository. When stating your issue be sure to add enough details, specify what module is causing the problem and reproduction steps.\n\n## Community\n\n[![Slack][slack-image]][slack-url]\n\nThe entire Zewo code base is licensed under MIT. By contributing to Zewo you are contributing to an open and engaged community of brilliant Swift programmers. Join us on [Slack](http://slack.zewo.io) to get to know us!\n\n## License\n\nThis project is released under the MIT license. See [LICENSE](LICENSE) for details.\n\n[swift-badge]: https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat\n[swift-url]: https://swift.org\n[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat\n[mit-url]: https://tldrlegal.com/license/mit-license\n[slack-image]: http://s13.postimg.org/ybwy92ktf/Slack.png\n[slack-badge]: https://zewo-slackin.herokuapp.com/badge.svg\n[slack-url]: http://slack.zewo.io\n[travis-badge]: https://travis-ci.org/Zewo/Reflection.svg?branch=master\n[travis-url]: https://travis-ci.org/Zewo/Reflection\n[codecov-badge]: https://codecov.io/gh/Zewo/Reflection/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/Zewo/Reflection\n[codebeat-badge]: https://codebeat.co/badges/85f3c10b-6574-4956-8c58-bb6ad3ea1268\n[codebeat-url]: https://codebeat.co/projects/github-com-zewo-reflection\n","funding_links":[],"categories":["Reflection","Swift","swiftpm"],"sub_categories":["React-Like","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZewo%2FReflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZewo%2FReflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZewo%2FReflection/lists"}