DictionaryCoding

0.2.1

Codable / [String:Any] bridge
krugazor/DictionaryCoding

What's New

0.2.1

2023-06-11T09:06:26Z

Updated for the latest Swift version as of June 2023

DictionaryCoder

A Swift 4 coder/decoder that maps standard types (dictionary, array) to Codable, and vice-versa

Usage

Let's assume we have a Codable type called Simple

Encoding:

let o = Simple(...)
let encoded = try DictionaryCoding().encode(o)
switch encoded {
	case .dictionary(let d): // do something with d
	default: // something went wrong, or maybe Simple is an Array?
}

Decoding:

let d = [...] // dictionary with the RIGHT keys
let o = try DictionaryCoding().decode(Simple.self, from: d)
// o is a Simple, or there was an exception

More info

I took the time to explain the whole process of creating that package in this blog post.

Licence

A long time ago, I went by the licence of people having to offer me a beer if they used the code and met me in real life, but the world is wider now 😉

Instead, this is under CC BY-SA 1.0

Description

  • Swift Tools 5.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 06:03:33 GMT-0900 (Hawaii-Aleutian Daylight Time)