Latest 3.0.1
Homepage https://github.com/spxrogers/Alamofire-Gloss
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0, watchos 2.0, requires ARC
Authors

CocoaPods
Carthagecompatible

Gloss bindings for Alamofire for easy-peasy JSON serialization.

Installation

CocoaPods

Add to your Podfile:

pod 'Alamofire-Gloss'

Carthage

github "spxrogers/Alamofire-Gloss"

Alamofire-Gloss lists Alamofire and Gloss as explicit Carthage dependencies, so it’s only
necessary to list Alamofire-Gloss in your Cartfile and it will pull down all
three libraries. Copy & Link generated frameworks as normal.

Usage

Define your Model

Create a Class or Struct which implements the Decodable (or Glossy) protocol.

import Foundation
import Gloss

struct Person: JSONDecodable {

  let name: String
  let age: Int?

  init?(json: JSON) {
    guard let name: String = "name" <~~ json
      else { return nil }

    self.name = name
    self.age = "age" <~~ json
  }
}

API

responseObject()
responseArray()

1. Example – mapObject

Alamofire.request(personUrl).responseObject(Person.self) { (response) in
  switch response.result {
  case .success(let person):
    print("Found person: (person)")
  case .failure(let error):
    print("Error'd: (error)")
  }
}

2. Example – mapArray

Alamofire.request(peopleUrl).responseArray(Person.self) { (response) in
  switch response.result {
  case .success(let people):
    print("Found people: (people)")
  case .failure(let error):
    print("Error'd: (error)")
  }
}

Contributing

Issues and pull requests are welcome!

Author

Steven Rogers @spxrogers

Thanks …

… to Harlan Kellaway for creating Gloss, my preferred JSON library :)

… to the Alamofire (+AFNetworking) team for paving the way of Networking in iOS.

License

Alamofire-Gloss is released under an MIT license. See LICENSE for more information.

Smile for a permissive license.

Latest podspec

{
    "name": "Alamofire-Gloss",
    "version": "3.0.1",
    "summary": "Convenience Gloss bindings for Alamofire.",
    "description": "[Gloss](https://github.com/hkellaway/Gloss) bindings forn[Alamofire](https://github.com/Alamofire/Alamofire) for easy-peasy JSON serialization.nInstructions on how to use it are inn[the README](https://github.com/spxrogers/Alamofire-Gloss).",
    "homepage": "https://github.com/spxrogers/Alamofire-Gloss",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "steven sogers": "[email protected]"
    },
    "source": {
        "git": "https://github.com/spxrogers/Alamofire-Gloss.git",
        "tag": "3.0.1"
    },
    "social_media_url": "https://twitter.com/spxrogers",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "requires_arc": true,
    "default_subspecs": "Core",
    "pushed_with_swift_version": "4.0",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Source/*.swift",
            "dependencies": {
                "Alamofire": [
                    "~> 4.6.0"
                ],
                "Gloss": [
                    "~> 2.0.0-beta.2"
                ]
            },
            "frameworks": "Foundation"
        }
    ]
}

Pin It on Pinterest

Share This