Arrow

suggest change

Arrow is an elegant JSON parsing library in Swift.

It parses JSON and maps it onto custom model types with the <-- operator:

identifier <-- json["id"]
name <-- json["name"]
stats <-- json["stats"]

Example:

Swift model

struct Profile {
    var identifier = 0
    var name = ""
    var link: NSURL?
    var weekday: WeekDay = .Monday
    var stats = Stats()
    var phoneNumbers = [PhoneNumber]()
}

JSON file

{
    "id": 15678,
    "name": "John Doe",
    "link": "https://apple.com/steve",
    "weekdayInt" : 3,
    "stats": {
        "numberOfFriends": 163,
        "numberOfFans": 10987
    },
    "phoneNumbers": [{
                     "label": "house",
                     "number": "9809876545"
                     }, {
                     "label": "cell",
                     "number": "0908070656"
                     }, {
                     "label": "work",
                     "number": "0916570656"
    }]
}

Mapping

extension Profile: ArrowParsable {
    mutating func deserialize(_ json: JSON) {
        identifier <-- json["id"]
        link <-- json["link"]
        name <-- json["name"]
        weekday <-- json["weekdayInt"]
        stats <-- json["stats"]
        phoneNumbers <-- json["phoneNumbers"]
    }
}

Usage

var profile = Profile()
profile.deserialize(json)

Installation:

Carthage

github "s4cha/Arrow"

CocoaPods

pod 'Arrow'
use_frameworks!

Manually

Copy Arrow.swift into your Xcode project.

https://github.com/s4cha/Arrow

As A Framework

Download Arrow from the GitHub repository and build the Framework target in the example project. Then link against that framework.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents