JSONResponseSerializer
@available(*, deprecated, message: "JSONResponseSerializer deprecated and will be removed in Alamofire 6. Use DecodableResponseSerializer instead.")
public final class JSONResponseSerializer : ResponseSerializer
A ResponseSerializer that decodes the response data using JSONSerialization. By default, a request returning
nil or no data is considered an error. However, if the request has an HTTPMethod or the response has an
HTTP status code valid for empty responses, then an NSNull value is returned.
Note
This serializer is deprecated and should not be used. Instead, create concrete types conforming toDecodable and use a DecodableResponseSerializer.
-
Declaration
Swift
public let dataPreprocessor: any DataPreprocessor -
Declaration
Swift
public let emptyResponseCodes: Set<Int> -
Declaration
Swift
public let emptyRequestMethods: Set<HTTPMethod> -
JSONSerialization.ReadingOptionsused when serializing a response.Declaration
Swift
public let options: JSONSerialization.ReadingOptions -
Creates an instance with the provided values.
Declaration
Swift
public init(dataPreprocessor: any DataPreprocessor = JSONResponseSerializer.defaultDataPreprocessor, emptyResponseCodes: Set<Int> = JSONResponseSerializer.defaultEmptyResponseCodes, emptyRequestMethods: Set<HTTPMethod> = JSONResponseSerializer.defaultEmptyRequestMethods, options: JSONSerialization.ReadingOptions = .allowFragments)Parameters
dataPreprocessorDataPreprocessorused to prepare the receivedDatafor serialization.emptyResponseCodesThe HTTP response codes for which empty responses are allowed.
[204, 205]by default.emptyRequestMethodsThe HTTP request methods for which empty responses are allowed.
[.head]by default.optionsThe options to use.
.allowFragmentsby default. -
Declaration
Swift
public func serialize(request: URLRequest?, response: HTTPURLResponse?, data: Data?, error: (any Error)?) throws -> Any
View on GitHub
Install in Dash