JSONEncoding
public struct JSONEncoding: ParameterEncoding
Uses JSONSerialization to create a JSON representation of the parameters object, which is set as the body of the
request. The Content-Type HTTP header field of an encoded request is set to application/json.
-
Returns a
JSONEncodinginstance with default writing options.Declaration
Swift
public static var `default`: JSONEncoding -
Returns a
JSONEncodinginstance with.prettyPrintedwriting options.Declaration
Swift
public static var prettyPrinted: JSONEncoding -
The options for writing the parameters as JSON data.
Declaration
Swift
public let options: JSONSerialization.WritingOptions
-
Creates a
JSONEncodinginstance using the specified options.Declaration
Swift
public init(options: JSONSerialization.WritingOptions = [])
-
Creates a URL request by encoding parameters and applying them onto an existing request.
Throws
An
Errorif the encoding process encounters an error.Declaration
Swift
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest
View on GitHub
JSONEncoding Struct Reference