{"id":20492534,"url":"https://github.com/redmadrobot/parser-autograph","last_synced_at":"2026-05-15T18:03:23.648Z","repository":{"id":63920386,"uuid":"112667594","full_name":"RedMadRobot/parser-autograph","owner":"RedMadRobot","description":"Object parser generation utility.","archived":false,"fork":false,"pushed_at":"2017-12-07T16:50:05.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-02-27T05:14:08.200Z","etag":null,"topics":["code-generation","ios","macos","parser","sourcekit","swift","template"],"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/RedMadRobot.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":"2017-11-30T22:24:31.000Z","updated_at":"2018-10-21T17:05:42.000Z","dependencies_parsed_at":"2023-01-14T14:00:52.208Z","dependency_job_id":null,"html_url":"https://github.com/RedMadRobot/parser-autograph","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fparser-autograph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fparser-autograph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fparser-autograph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fparser-autograph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedMadRobot","download_url":"https://codeload.github.com/RedMadRobot/parser-autograph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242073744,"owners_count":20067898,"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":["code-generation","ios","macos","parser","sourcekit","swift","template"],"created_at":"2024-11-15T17:29:29.808Z","updated_at":"2025-10-28T07:08:08.105Z","avatar_url":"https://github.com/RedMadRobot.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parser Autograph\n\nObject parser generation utility based on [Autograph](https://github.com/RedMadRobot/autograph) and [Synopsis](https://github.com/RedMadRobot/synopsis) frameworks.\n\n# Usage\n## Prepare your sources\n\nMark your model classes and structures like this:\n\n```swift\n/**\n EVERYTHING Codable OR Decodable IS CONSIDERED A MODEL\n */\nstruct Person: Decodable {\n    /**\n     PROVIDE JSON KEYS FOR EACH PROPERTY:\n     @json first_name\n     */\n    let firstName: String\n    \n    /**\n     USE OPTIONAL PROPERTY TYPES FOR OPTIONAL FIELDS e.g. String?\n     USE NON-OPTIONAL TYPES FOR MANDATORY FIELDS     e.g. String\n     @json last_name\n     */\n    let lastName: String?\n    \n    /**\n     FEEL FREE TO USE OTHER ANNOTATED MODELS AS SUB-OBJECTS e.g. Passport\n     PROPERTY NAMES ARE USED AS IMPLICIT JSON KEYS:\n     @json\n     */\n    let passport: Passport?\n}\n```\n\n**Parser Autograph** will generate a generic `object parser` utility class for you, and also `Decodable` extensions for each of your models.\n\n`Object parser` utility works as you would expect:\n\n```swift\nlet parser: ObjectParser\u003cPerson\u003e = ObjectParser()\nparser.logErrors = true // error logging is disabled by default\n\nlet data = \"\"\"\n{ \n    \"data\": [\n        { \"first_name\": \"Jack\", \"last_name\": \"Daniel\" }, \n        { \"first_name\": \"Jim Beam\" }\n    ]\n}\n\"\"\".data(using: String.Encoding.utf8)!\n\nlet result: [Person] = parser.parse(data: data) // see also parse(any:), parse(dictionary:) and parse(array:)\n\nprint(result.count) // two guys here\n```\n\n## Build executable\n\nRun `spm_build.command` script in order to build from sources.\n\nYou'll find your `ParserAutograph` executable in `./build/x86_64-apple-macosx10.10/release` folder or similar, depending on your OS.\n\n## Add run script build phase to your project\n\nRun `ParserAutograph` executable before other build phases, so that new generated source code would be taken into the process.\nThe utility accepts next arguments:\n\n* `-help` — print help, do not execute;\n* `-verbose` — print additional debug information;\n* `-input [folder]` — path to the folder with your model classes and structures;\n* `-output [folder]` — path to the folder, where to put generated `ObjectParser.swift` file.\n\nYour script may look like this:\n\n```bash\nPARSER_AUTOGRAPH_PATH=Utilities/ParserAutograph\n\nif [ -f $PARSER_AUTOGRAPH_PATH ]\nthen\n    echo \"ParserAutograph executable found\"\nelse\n    osascript -e 'tell app \"Xcode\" to display dialog \"Object parser generator executable not found in \\nUtilities/ParserAutograph\" buttons {\"OK\"} with icon caution'\nfi\n\n$PARSER_AUTOGRAPH_PATH \\\n    -input \"$PROJECT_NAME/Classes/Model\" \\\n    -output \"./$PROJECT_NAME/Generated/Classes\"\n```\n\n## Demo \u0026 running tests\n\nUse `spm_resolve.command` to load all dependencies and `spm_generate_xcodeproj.command` to assemble an Xcode project file.\nAlso, ensure Xcode targets macOS.\n\nRun `spm_run_sandbox.command` script for a demo — it builds and launches **Parser Autograph** with `Sources/Sandbox` as a working directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredmadrobot%2Fparser-autograph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredmadrobot%2Fparser-autograph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredmadrobot%2Fparser-autograph/lists"}