Latest 1.0.2
Homepage https://github.com/wolfmcnally/WolfAnyCodable
License MIT
Platforms ios 9.3, osx 10.13, tvos 11.0
Authors

CI Status
Version
License
Platform

Swift type-erased wrappers for Encodable, Decodable, and Codable values.

This cocoapod exists to easily incorporate the functionality of AnyCodable.

This functionality is discussed in Chapter 3 of Flight School Guide to Swift Codable.

AnyEncodable

import AnyCodable

let dictionary: [String: AnyEncodable] = [
    "boolean": true,
    "integer": 1,
    "double": 3.14159265358979323846,
    "string": "string",
    "array": [1, 2, 3],
    "nested": [
        "a": "alpha",
        "b": "bravo",
        "c": "charlie"
    ]
]

let encoder = JSONEncoder()
let json = try! encoder.encode(dictionary)

AnyDecodable

let json = """
     {
         "boolean": true,
         "integer": 1,
         "double": 3.14159265358979323846,
         "string": "string",
         "array": [1, 2, 3],
         "nested": {
             "a": "alpha",
             "b": "bravo",
             "c": "charlie"
         }
     }
""".data(using: .utf8)!

let decoder = JSONDecoder()
let dictionary = try! decoder.decode([String: AnyDecodable].self, from: json)

AnyCodable

AnyCodable can be used to wrap values for encoding and decoding.

License

MIT

Original Author

Mattt (@mattt)

Requirements

Swift 4.2

Installation

WolfAnyCodable is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'WolfAnyCodable'

Author

Wolf McNally, [email protected]

License

WolfAnyCodable is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "WolfAnyCodable",
    "version": "1.0.2",
    "summary": "Swift type-erased wrappers for Encodable, Decodable, and Codable values.",
    "description": "Swift type-erased wrappers for Encodable, Decodable, and Codable values.nCocoapod based on https://github.com/Flight-School/AnyCodable",
    "homepage": "https://github.com/wolfmcnally/WolfAnyCodable",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Wolf McNally": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wolfmcnally/WolfAnyCodable.git",
        "tag": "1.0.2"
    },
    "source_files": "WolfAnyCodable/Classes/**/*",
    "swift_version": "4.2",
    "platforms": {
        "ios": "9.3",
        "osx": "10.13",
        "tvos": "11.0"
    },
    "module_name": "WolfAnyCodable"
}

Pin It on Pinterest

Share This