Skip to content

tarunon/Illuso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Illuso

Build Status Carthage compatible Swift Package Manager

Illuso is JSON encoder for swift.

Summary

let json = try! encode(CGRectZero)
print(try! json.stringify())

Illuso can encode struct, class, enum.
Any code for encoding is not required in Illuso.

Custom Encoding

Unfortunately, some of Objective-C Class (e.g. NSURL, NSDate, UIView ...) is unsupported in Illuso. (returned empty dictionary)
If you want to encode these types, can use Encodable protocol.

extension URL: Encodable {
    func encode() throws -> JSON {
        return try encode(self.absoluteString)
    }
}

Of course Encodable can be implemented at Struct, and Class.

Installation

Carthage

github "tarunon/Illuso"

Swift Package Manager

.Package(url: "https://github.com/tarunon/Illuso.git", Version(0, 4, 1))

for Swift 3.x

Version 4.3 supoprt Swift 3.

LICENSE

MIT

Motivate

In swift, we may use awesome JSON decoding tools Argo, or Himotoki, but these cannot encode.
Illuso is required no coding because used Mirror, so we can use with Argo or Himotoki without conflict!!