Wrap is a Swift library from John Sundell easily encode Swift classes, structs or enums as JSON data.
The key advantage of Wrap is the simplicity, and for more advanced objects that may not have simple data types you can create custom keys, and key types.
This code snippet from the readme shows how one could encode a simple object:
let name: String
let age: Int
}
let user = User(name: "John", age: 28)
let dictionary: [String : AnyObject] = try Wrap(user)
This would produce the Dictionary with the data:
"name": "John",
"age": 28
}
You can find Wrap on Github here.
A nice simple way to encode Swift data as JSON.
Original article: Swift Library For Easily Encoding Classes, Structs, And Enums To JSON Data
©2016 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.
Reference source: iOS App Dev Libraries, Controls, Tutorials, Examples and Tools