{"id":15131256,"url":"https://github.com/hkellaway/gloss","last_synced_at":"2025-09-28T22:31:25.214Z","repository":{"id":54618644,"uuid":"40102424","full_name":"hkellaway/Gloss","owner":"hkellaway","description":"[Deprecated] A shiny JSON parsing library in Swift :sparkles: Loved by many from 2015-2021","archived":true,"fork":false,"pushed_at":"2021-02-08T05:44:26.000Z","size":1049,"stargazers_count":1626,"open_issues_count":0,"forks_count":142,"subscribers_count":36,"default_branch":"main","last_synced_at":"2024-04-11T13:08:42.200Z","etag":null,"topics":["json","json-parsing","swift"],"latest_commit_sha":null,"homepage":"https://hkellaway.github.io/blog/2020/08/30/tale-of-third-parties","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/hkellaway.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-08-03T03:03:16.000Z","updated_at":"2024-03-10T19:59:51.000Z","dependencies_parsed_at":"2022-08-13T21:40:55.210Z","dependency_job_id":null,"html_url":"https://github.com/hkellaway/Gloss","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkellaway%2FGloss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkellaway%2FGloss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkellaway%2FGloss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkellaway%2FGloss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hkellaway","download_url":"https://codeload.github.com/hkellaway/Gloss/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234569704,"owners_count":18854133,"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":["json","json-parsing","swift"],"created_at":"2024-09-26T03:40:18.929Z","updated_at":"2025-09-28T22:31:24.915Z","avatar_url":"https://github.com/hkellaway.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Gloss](https://github.com/hkellaway/Gloss/raw/main/img/Gloss_Logo_Word_Tagline.png)\n\n## :rotating_light: Deprecation Notice :rotating_light:\n\nGloss has been deprecated in favor of Swift's [Codable](https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types) framework.\n\nThe existing Gloss source is not going away, however updates will only be made to support migration to Codable. Read the [MIGRATION GUIDE](GLOSS_CODABLE_MIGRATION_GUIDE.md) now to get started.\n\n*If you do not yet have any Gloss models in your project* yet are considering it for JSON parsing, turn around now! Select Swift's Codable framework instead.\n\n## I understand, I'm Using Gloss Anyway\n\n![Swift version](https://img.shields.io/badge/Swift-5.0-orange.svg)\n[![CocoaPods](https://img.shields.io/cocoapods/v/Gloss.svg)](http://cocoapods.org/pods/Gloss) \n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage) \n[![SPM](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) \n[![CocoaPods](https://img.shields.io/cocoapods/p/Gloss.svg)](http://cocoapods.org/pods/Gloss)\n[![Build Status](https://travis-ci.org/hkellaway/Gloss.svg?branch=main)](https://travis-ci.org/hkellaway/Gloss)\n\nSee the [former README.md](README_ARCHIVE.md) on instructions for using Gloss pre-Codable migration.\n\n### Credits\n\nGloss was created by [Harlan Kellaway](http://hkellaway.github.io) \n\nThank you to all [contributors](https://github.com/hkellaway/Gloss/contributors) and the Swift community for 5 years of Gloss! :sparkling_heart:\n\n### License [![License](https://img.shields.io/cocoapods/l/Gloss.svg)](https://raw.githubusercontent.com/hkellaway/Gloss/main/LICENSE)\n\nSee the [LICENSE](https://raw.githubusercontent.com/hkellaway/Gloss/main/LICENSE) file for more info.\n\n## Codable Migration Quick Reference\n\nThe following is a reference for what your Gloss models and call-sites should look like after preparing to migrate to Codable.\n\nSee the [MIGRATION GUIDE](GLOSS_CODABLE_MIGRATION_GUIDE.md) for more detail.\n\n### Version\n\nUse version `3.2.0` or higher to take advantage of migration helpers.\n\n### Deserialization\n\nGiven a Gloss model that conforms to `JSONDecodable`, add conformance to `Decodable`. A model that looks like this:\n\n``` swift\nimport Gloss\n\nstruct MyModel: JSONDecodable {\n    let id: Int?\n    \n    init?(json: JSON) {\n        self.id = \"id\" \u003c~~ json\n    }\n}\n```\n\nadds\n\n``` swift\nextension MyModel: Decodable {\n\n    init(from decoder: Swift.Decoder) throws {\n        // Proper Decodable definition or throw GlossError.decodableMigrationUnimplemented\n        // Remove this method if Codable can synthesize decoding for you\n    }\n\n}\n```\n\n### Initializing a Model from JSON\n\nWhere initializing that model currently looks like:\n\n``` swift\nlet myModel = MyModel(json: someJSON)\n```\n\nit becomes:\n\n``` swift\nlet myModel: MyModel = .from(decodableJSON: someJSON)\n```\n\n### Serialization\n\nGiven a Gloss model that conforms to `JSONEncodable`, add conformance to `Encodable`. A model that looks like this:\n\n``` swift\nimport Gloss\n\nstruct MyModel: JSONEncodable {\n    let id: Int?\n    \n    func toJSON() -\u003e JSON? {\n        return jsonify([\"id\" ~~\u003e self.id])\n    }\n}\n```\n\nadds\n\n``` swift\nextension MyModel: Encodable {\n\n    func encode(to encoder: Swift.Encoder) throws {\n        // Proper Encodable defintion or throw GlossError.encodableMigrationUnimplemented\n        // Remove this method if Codable can synthesize encoding for you\n    }\n\n}\n```\n\n### Translating Model Objects to JSON\n\nWhere translating to JSON currently looks like this:\n\n\n``` swift\nlet json: JSON? = myModel.toJSON()\n```\nit becomes:\n\n``` swift\nlet json: JSON? = myModel.toEncodableJSON()\n```\n\n### JSON Arrays\n\nSimilar usage applies to arrays of `Decodable` and `Encodable` models, with `from(decodableJSONArray:)` and `toEncodableJSONArray()` respectively.\n\n### Configuring `JSONDecoder` and `JSONEncoder`\n\nIf your Codable definitions are sound but you're encountering Codable errors, make sure your `JSONDecoder` or `JSONEncoder` instances are configured properly and pass them at call-sites:\n\n``` swift\nlet mySharedJSONDecoder: JSONDecoder = ...\nlet myModel: MyModel = .from(decodableJSON: someJSON, jsonDecoder: mySharedJSONDecoder)\n```\n\n``` swift\nlet mySharedJSONEncoder: JSONEncoder = ...\nlet json: JSON? = myModel.toEncodableJSON(jsonEncoder: mySharedJSONEncoder)\n```\n\n### Using `Data` Instead of `JSON` to Create Models\n\nIn the places where you've come to rely on Gloss's `JSON` type, you'll eventually need to pass `Data`, as that is what Codable uses. To get a jump using `decode(:)`, one option is use the same method Gloss uses to do `Data` transformation:\n\n\n``` swift\nimport Gloss\n\nlet sharedGlossSerializer: GlossJSONSerializer = ...\nlet json: JSON = ...\nif let data: Data? = sharedGlossSerializer.data(from: json, options: nil) {\n    let myModel: MyModel = try? myJSONDecoder.decode(MyModel.self, from : data)\n    ...\n}\n```\n\nTake the opportunity with this migration to pare your models down to the slim amount of code Codable needs to work its magic and detangle your networking code from the details of JSON serialization. Future you will be grateful! :crystal_ball:\n\n:sparkles::sparkles::sparkles:`EOF`:sparkles::sparkles::sparkles:\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkellaway%2Fgloss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkellaway%2Fgloss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkellaway%2Fgloss/lists"}