The better way to deal with JSON data in Swift
open sourceMITfree
SwiftyJSON makes JSON easier to work with in Swift, whose strict typing makes nested JSON from JSONSerialization a chain of optional casts. A JSON value is read by subscripting with keys and indexes, looped over, and converted with optional getters that return nil or non-optional getters that fall back to a default, with errors for missing keys or wrong types. It can also set values, build JSON from literals, merge two JSON values, remove elements and get the raw object back. Its README shows it with Alamofire and Moya. It installs with CocoaPods, Carthage or Swift Package Manager.
Problems it solves
- read nested JSON in Swift without a chain of optional casts
- parse a JSON API response in my iOS app quickly
- safely get a value from deeply nested JSON in Swift
Features
- subscript JSON by key and index
- optional and non-optional getters
- errors for missing keys and wrong types
- setters and literal convertibles
- merge JSON values
- remove elements
- raw object access
- CocoaPods, Carthage and Swift Package Manager
