Swiftpack.co -  Package - Enchan1207/Serializable
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Enchan1207/Serializable
Extended Codable Protocol
.package(url: "https://github.com/Enchan1207/Serializable.git", from: "v1.0.0")

Serializable

Overview

Extended Codable Protocol

Usage

First, make the structure compliant with the protocol Serializable.

struct Article: Serializable {
    let id: String
    let title: String
    let tag: [String]
    let content: String
}

Serialize (object to JSON string):

let article = Article(id: "001", title: "Hello!", tag: ["Introduction"], content: "# Hi there! I'm Enchan.")

let serialized = article.serialize()!
print(serialized)

Deserialize (JSON string to object):

let deserialized = "{"id":"001","title":"Hello!","content":"# Hi there! I'm Enchan.","tag":["Introduction"]}"

let article = Article.deserialize(object: deserialized)!
print(article)

License

This repository is published under MIT License.
In details, see LICENSE.

GitHub

link
Stars: 0
Last commit: 6 days ago

Release Notes

6 days ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco