Deprecation Notice
Gloss has been deprecated in favor of Swift's Codable framework.
The existing Gloss source is not going away, however updates will only be made to support migration to Codable. Read the MIGRATION GUIDE now to get started.
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.
I understand, I'm Using Gloss Anyway
See the former README.md on instructions for using Gloss pre-Codable migration.
Credits
Gloss was created by Harlan Kellaway
Thank you to all contributors and the Swift community for 5 years of Gloss! :sparkling_heart:
License 
See the LICENSE file for more info.
Codable Migration Quick Reference
The following is a reference for what your Gloss models and call-sites should look like after preparing to migrate to Codable.
See the MIGRATION GUIDE for more detail.
Version
Use version 3.2.0
or higher to take advantage of migration helpers.
Deserialization
Given a Gloss model that conforms to JSONDecodable
, add conformance to Decodable
. A model that looks like this:
adds
Initializing a Model from JSON
Where initializing that model currently looks like:
it becomes:
Serialization
Given a Gloss model that conforms to JSONEncodable
, add conformance to Encodable
. A model that looks like this:
adds
Translating Model Objects to JSON
Where translating to JSON currently looks like this:
it becomes:
JSON Arrays
Similar usage applies to arrays of Decodable
and Encodable
models, with from(decodableJSONArray:)
and toEncodableJSONArray()
respectively.
Configuring JSONDecoder
and JSONEncoder
If 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:
Using Data
Instead of JSON
to Create Models
In 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:
Take 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: