Request

class Request

Extension to Alamofire.Request for adding a response serialized as a SwiftyJSON object.

  • Creates a response serializer that returns an object constructed from the response data using JSON(data:options:error:) with the specified reading options. Errors are passed as a .Failed event.

    Declaration

    Swift

    public static func swiftyJSONResponseSerializer(
            options options: NSJSONReadingOptions = .AllowFragments)
            -> ResponseSerializer<JSON, NSError>

    Parameters

    options

    The json reading options. .AllowFragments by default.

    Return Value

    A JSON object response serializer.

  • Adds a handler to be called once the request has finished.

    Declaration

    Swift

    public func responseSwiftyJSON(
            options options: NSJSONReadingOptions = .AllowFragments,
            completionHandler: Response<JSON, NSError> -> Void)
            -> Self

    Parameters

    options

    The json reading options. .AllowFragments by default.

    completionHandler

    A closure to be executed once the request has finished. The closure takes a single argument, the Alamofire Response<JSON, NSError>.

    Return Value

    The request.

  • Convenience ReactiveCocoa response using a swiftyJSONResponseSerializer().

    Seealso

    rac_response(_:responseSerializer:)

    Declaration

    Swift

    public func rac_responseSwiftyJSON(queue: dispatch_queue_t? = nil) -> SignalProducer<JSON, NSError>
  • Convenience ReactiveCocoa response using a swiftyJSONResponseSerializer() that transforms the JSON to a JSONCreated object.

    Declaration

    Swift

    public func rac_responseSwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, T), NSError>

    Return Value

    A SignalProducer with either the JSONCreated object as its value or the thrown error from init(json:).

  • Convenience ReactiveCocoa response using a swiftyJSONResponseSerializer() that transforms the JSON to an array of JSONCreated objects.

    Declaration

    Swift

    public func rac_responseArraySwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, [T]), NSError>

    Return Value

    A SignalProducer with an array of all the JSONCreated objects that didn’t throw errors. The original JSON is returned alongside the transformed objects for transparency. This allows the caller to check the JSON count against the transformed count. If the JSON returned from the swiftyJSONResponseSerializer() is not an Array the SignalProducer has an error created from unexpectedTypeErrorForJSON(_:expectedType:).

  • Convenience ReactiveCocoa response using a swiftyJSONResponseSerializer() that transforms the JSON to a dictionary of JSONCreated objects.

    Declaration

    Swift

    public func rac_responseDictionarySwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, [String:T]), NSError>

    Return Value

    A SignalProducer with a dictionary of all the JSONCreated objects that didn’t throw errors. The original JSON is returned alongside the transformed objects for transparency. This allows the caller to check the JSON count against the transformed count. If the JSON returned from the swiftyJSONResponseSerializer() is not a Dictionary the SignalProducer has an error created from unexpectedTypeErrorForJSON(_:expectedType:).