{"id":1720,"url":"https://github.com/ra1028/Alembic","last_synced_at":"2025-08-06T13:32:06.177Z","repository":{"id":56901758,"uuid":"55307868","full_name":"ra1028/Alembic","owner":"ra1028","description":":alembic: Functional JSON Parser - Linux Ready :penguin:","archived":false,"fork":false,"pushed_at":"2018-09-30T18:51:06.000Z","size":3770,"stargazers_count":116,"open_issues_count":2,"forks_count":8,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-27T10:55:58.923Z","etag":null,"topics":["alembic","functional","ios","json","linux","monad","parser","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/ra1028.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-04-02T17:41:26.000Z","updated_at":"2023-09-28T23:51:37.000Z","dependencies_parsed_at":"2022-08-20T18:10:11.939Z","dependency_job_id":null,"html_url":"https://github.com/ra1028/Alembic","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FAlembic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FAlembic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FAlembic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FAlembic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ra1028","download_url":"https://codeload.github.com/ra1028/Alembic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228905444,"owners_count":17989767,"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":["alembic","functional","ios","json","linux","monad","parser","swift"],"created_at":"2024-01-05T20:15:54.208Z","updated_at":"2024-12-09T14:30:44.548Z","avatar_url":"https://github.com/ra1028.png","language":"Swift","funding_links":[],"categories":["Parsing","Libs","Parser","Data and Storage","Data Management [🔝](#readme)"],"sub_categories":["JSON","Data Management","Other free courses"],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ra1028/Alembic/master/Assets/Alembic_Logo.png\" alt=\"Alembic\" width=\"70%\"\u003e\n\u003c/p\u003e\n\u003cH4 align=\"center\"\u003eFunctional JSON Parser\u003c/H4\u003e\n\u003c/br\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg alt=\"Swift4\" src=\"https://img.shields.io/badge/language-swift4-orange.svg?style=flat\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/ra1028/Alembic\"\u003e\u003cimg alt=\"Build Status\" src=\"https://travis-ci.org/ra1028/Alembic.svg?branch=master\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://codebeat.co/projects/github-com-ra1028-alembic\"\u003e\u003cimg alt=\"CodeBeat\" src=\"https://codebeat.co/badges/09cc20c0-4cba-4c78-8e20-39f41d86c587\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c/br\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://cocoapods.org/pods/Alembic\"\u003e\u003cimg alt=\"CocoaPods\" src=\"https://img.shields.io/cocoapods/v/Alembic.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\u003cimg alt=\"Carthage\" src=\"https://img.shields.io/badge/Carthage-compatible-yellow.svg?style=flat\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/apple/swift-package-manager\"\u003e\u003cimg alt=\"Swift Package Manager\" src=\"https://img.shields.io/badge/SwiftPM-compatible-blue.svg\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c/br\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://developer.apple.com/swift/\"\u003e\u003cimg alt=\"Platform\" src=\"https://img.shields.io/badge/platform-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-green.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ra1028/Alembic/blob/master/LICENSE\"\u003e\u003cimg alt=\"Lincense\" src=\"http://img.shields.io/badge/license-MIT-000000.svg?style=flat\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Feature\n- Linux Ready\n- Type-safe JSON parsing\n- Functional value transformation\n- Easy to parse nested value\n- Dependency free\n- No defined custom operators\n\n---\n\n## Requirements\n- Swift4.1 or later\n- OS X 10.9 or later\n- iOS 9.0 or later\n- watchOS 2.0 or later\n- tvOS 9.0 or later\n- Linux\n\n---\n\n## Installation\n\n### [CocoaPods](https://cocoapods.org/)  \nAdd the following to your Podfile:  \n```ruby\nuse_frameworks!\n\ntarget 'TargetName' do\n  pod 'Alembic'\nend\n```\n\n### [Carthage](https://github.com/Carthage/Carthage)  \nAdd the following to your Cartfile:  \n```ruby\ngithub \"ra1028/Alembic\"\n```\n\n### [Swift Package Manager](https://github.com/apple/swift-package-manager)\nAdd the following to your Package.swift:  \n```Swift\n// swift-tools-version:4.0\n\nlet package = Package(\n    name: \"ProjectName\",\n    dependencies : [\n        .package(url: \"https://github.com/ra1028/Alembic.git\", .upToNextMajor(from: \"3\"))\n    ]\n)\n```\n\n---\n\n## Example  \nIn example, parse the following JSON:  \n```json\n{\n    \"teams\": [\n        {\n            \"name\": \"Team ra1028\",\n            \"url\": \"https://github.com/ra1028\",\n            \"members\": [\n                {\n                    \"name\": \"Ryo Aoyama\",\n                    \"age\": 23\n                },\n                {\n                    \"name\": \"John Doe\",\n                    \"age\": 30\n                }\n            ]\n        }\n    ]\n}\n```\n\n#### Make the JSON instance from `Any`, `Data` or `String` type JSON object.\n```swift\n// from `Any` type JSON object\nlet json = JSON(object)\n```\n```swift\n// from JSON Data\nlet json = try JSON(data: data)\n```\n```swift\n// from JSON String\nlet json = try JSON(string: string)\n```\n\n#### Parse value from JSON:\n__Parse the values type-safely__\n```swift\nlet memberName: String = try json.value(for: [\"teams\", 0, \"members\", 0, \"name\"])\n```\n__Parse nullable value__\n```swift\nlet missingText: String? = try json.option(for: \"missingKey\")\n```\n\n#### Parse value from JSON with transforming:\n__Transform value using various monadic functions.__\n```swift\nlet teamUrl: URL = try json.parse(String.self, for: [\"teams\", 0, \"url\"])\n        .filterMap(URL.init(string:))\n        .value()\n```\n__Transform nullable value if exist__\n```swift\nlet missingUrl: URL? = try json.parse(String.self, for: \"missingKey\")\n        .filterMap(URL.init(string:))\n        .option()\n```\n\n#### Mapping to model from JSON:\n__All types conforming to `Parsable` protocol and it's Array, Dictionary can be parsed.__  \n```swift\nstruct Member: Parsable {\n    let name: String\n    let age: Int\n\n    static func value(from json: JSON) throws -\u003e Member {\n        return try .init(\n            name: json.value(for: \"name\"),\n            age: json.value(for: \"age\")\n        )\n    }\n}\n\nextension URL: Parsable {\n    public static func value(from json: JSON) throws -\u003e URL {\n        guard let url = try URL(string: json.value()) else {\n            throw JSON.Error.dataCorrupted(value: json.rawValue, description: \"The value was not valid url string.\")\n        }\n        return url\n    }\n}\n\nstruct Team: Parsable {\n    let name: String\n    let url: URL\n    let members: [Member]\n\n    static func value(from json: JSON) throws -\u003e Team {\n        return try .init(\n            name: json.value(for: \"name\"),\n            url: json.value(for: \"url\"),\n            members: json.value(for: \"members\")\n        )\n    }\n}\n```\n```swift\nlet team: Team = try json.value(for: [\"teams\", 0])\n```\n\n---\n\n## Tips\n#### The types conformed to `Parsable` as default.  \n```swift\nJSON\nString\nInt\nUInt\nDouble\nFloat\nBool\nNSNumber\nInt8\nUInt8\nInt16\nUInt16\nInt32\nUInt32\nInt64\nUInt64\nDecimal\nArray where Element: Parsable\nDictionary where Key == String, Value: Parsable\nOptional where Wrapped: Parsable\n```\n\n#### Conform to `Parsable` with initializer\n```swift\nstruct Member: ParseInitializable {\n    let name: String\n    let age: Int\n\n    init(with json: JSON) throws {\n        name = try json.value(for: \"name\")\n        age = try json.value(for: \"age\")\n    }\n}\n```\n\n#### Usage Reference Files\nFunctional operators for value transforming:\n- [ParserProtocol.swift](./Sources/ParserProtocol.swift)\n- [Parser.swift](./Sources/Parser.swift)\n- [ThrowParser.swift](./Sources/ThrowParser.swift)\n\nErrors\n- [Error.swift](./Sources/Error.swift)\n\n#### More Example\nSee the [Test files](./Tests/AlembicTests)\n\n---\n\n## Playground\n1. Open Alembic.xcworkspace.\n2. Build the Alembic for Mac.\n3. Open Alembic playground in project navigator.\n\n---\n\n## Contribution\nWelcome to fork and submit pull requests!\n\nBefore submitting pull request, please ensure you have passed the included tests.\nIf your pull request including new function, please write test cases for it.\n\n---\n\n## License\nAlembic is released under the MIT License.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fra1028%2FAlembic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fra1028%2FAlembic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fra1028%2FAlembic/lists"}