{"id":23012396,"url":"https://github.com/forgwhiz/flexijsoncoder","last_synced_at":"2026-02-01T16:35:46.644Z","repository":{"id":267459810,"uuid":"901315021","full_name":"Forgwhiz/FlexiJSONCoder","owner":"Forgwhiz","description":"FlexiJSONCoder is a Swift library that simplifies decoding JSON data with type coercion and fallback support. It handles inconsistent data structures by automatically converting fields to the expected types","archived":false,"fork":false,"pushed_at":"2024-12-11T07:02:54.000Z","size":49,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-25T16:28:16.429Z","etag":null,"topics":["cocoapods","datatypeconversion","framework","jsondecoder","jsonencoder","swift","swift-package-manager"],"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/Forgwhiz.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":"2024-12-10T12:40:18.000Z","updated_at":"2025-02-26T10:36:27.000Z","dependencies_parsed_at":"2024-12-10T13:42:25.668Z","dependency_job_id":"31bed9b8-d84c-49f5-99ff-d71d25bd5096","html_url":"https://github.com/Forgwhiz/FlexiJSONCoder","commit_stats":null,"previous_names":["forgwhiz/flexijsoncoder"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Forgwhiz/FlexiJSONCoder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forgwhiz%2FFlexiJSONCoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forgwhiz%2FFlexiJSONCoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forgwhiz%2FFlexiJSONCoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forgwhiz%2FFlexiJSONCoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Forgwhiz","download_url":"https://codeload.github.com/Forgwhiz/FlexiJSONCoder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Forgwhiz%2FFlexiJSONCoder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28983032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T16:29:42.054Z","status":"ssl_error","status_checked_at":"2026-02-01T16:29:41.428Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cocoapods","datatypeconversion","framework","jsondecoder","jsonencoder","swift","swift-package-manager"],"created_at":"2024-12-15T10:13:58.117Z","updated_at":"2026-02-01T16:35:46.631Z","avatar_url":"https://github.com/Forgwhiz.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Static Badge](https://img.shields.io/badge/Platform-iOS-blue)\n![Static Badge](https://img.shields.io/badge/iOS-13.0%2B-orange)\n![Static Badge](https://img.shields.io/badge/SwiftPM-Compatible-green)\n![Static Badge](https://img.shields.io/badge/pod-v0.0.1-blue)\n![Static Badge](https://img.shields.io/badge/Licence-MIT-black)\n![Static Badge](https://img.shields.io/badge/OpenSource-red)\n![Static Badge](https://img.shields.io/badge/Swift%20Tests-passing-green?logo=github\u0026link=image)\n\n\n# FlexiJSONCoder for Swift\n\n**FlexiJSONCoder** is a lightweight, flexible, and easy-to-use library for decoding JSON data into Swift types, providing **type coercion** with fallback support. It allows you to seamlessly handle different data types coming from a JSON response and automatically convert them to the expected types in your model. \n\nThis library is especially useful when dealing with API responses that may contain multiple types for a single field (e.g., `String`, `Int`, `Float`, `Double`, etc.), making it easier to work with inconsistent data structures.\n\n\n## Features:\n\n- **Default Value Handling**: Automatically applies default values for any missing keys or values in the JSON.\n- **Type Coercion**: Converts incoming data types (e.g., String, Int, Float, Double, Bool) to the model's expected type seamlessly.\n- **Null Value Management**: Replaces null values with predefined default values, ensuring smooth processing.\n- **Data Integrity**: Generates clear and actionable errors for unsupported type conversions while maintaining data consistency.\n- **Easy Integration**: Compatible with your existing Swift codebase and leverages the Decodable protocol.\n- **Customizable**: Supports extensions for additional data types, such as Date, URL, and more, for future-proof development\n\n## Supported Datatypes :\n**Version 0.0.1**: This release with support for `String`, `Int`, `Float`, `Double`, and `Bool` coercion.\n\n## Example\n\n[Download the example project](https://github.com/Forgwhiz/DecoderExample)\n\n## Installation\n\nFlexiJSONCoder is available through [Swift Package Manager](https://swiftpackageindex.com/Forgwhiz/FlexiJSONCoder)\n\n## Features \u003ca id='ssFeatures'\u003e\u003c/a\u003e\n\n### Swift Package Manager\n\n- In Xcode select:\n\n```ruby\nFile \u003e Swift Packages \u003e Add Package Dependency...\n```\n- Then paste this URL:\n\n```ruby\nhttps://github.com/Forgwhiz/FlexiJSONCoder.git\n```\n\n### Cocoapods\n\nAdd the following line to your `Podfile`:\n\n```ruby\npod 'FlexiJSONCoder', '~\u003e 0.0.1'\n```\n\nThen run:\n\n```bash\npod install\n```\n\nor\n\n```bash\npod update\n```\n\n\n## Demo\n\n### Basic Usage\n\nUsage of the library is simple and can be seen in the example provided below. Here's how to use **FlexiJSONCoder** in your Swift model:\n\n```swift\n\nimport FlexiJSONCoder\n\nstruct WelcomeModel: Codable {\n    let id: String?\n    let title: String\n    let type: Int?\n    let category: Float?\n}\n\nlet jsonData = \"\"\"\n{\n    \"id\": \"123\",\n    \"title\": \"Welcome\",\n    \"category\": \"45.67\",\n    \"isActive\": \"true\",\n}\n\"\"\".data(using: .utf8)!\n\ndo {\n    let jsonData = try JSONSerialization.data(withJSONObject: dictionary, options: [.fragmentsAllowed])\n    let decodedModel = try FlexiJSONCoder().decode(WelcomeModel.self, from: jsonData)\n    print(decodedModel)  // Outputs: WelcomeModel(id: \"123\", title: \"Welcome\", type: 0, category: 45.67, isActive: true)\n} catch {\n    print(\"Decoding failed: \\(error)\")\n}\n```\n\n### Options for Custom Types\n\nWhile the basic functionality works out of the box for `String`, `Int`, `Float`, `Double`, and `Bool`, you can extend the functionality in the future as needed. **FlexiJSONCoder** is built with extensibility in mind.\n\n### Supported Types\n\n| Command | Description |\n| --- | --- |\n| `String` | Can be converted from `String`, `Int`, `Float`, `Double` |\n| `Int` | Can be converted from `String`, `Float`, `Double` |\n| `Float` | Can be converted from `String`, `Int`, `Double` |\n| `Double` | Can be converted from `String`, `Int`, `Float` |\n| `Bool` | Can be converted from `String` (\"true\"/\"false\") or `Int` (1 for `true`, 0 for `false`) |\n\n\n### Customizing for Future Types\n\nYou can extend the library to support additional types (like `Date`, `URL`, etc.)\n\n## License\n\n**FlexiJSONCoder** is available under the MIT license. See the [LICENSE](LICENSE) file for more information.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforgwhiz%2Fflexijsoncoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforgwhiz%2Fflexijsoncoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforgwhiz%2Fflexijsoncoder/lists"}