Json
The JSON HTTP body is presumably the most commonly used non-empty body for HTTP requests. It encodes an encodable type as JSON and sets the body of an HTTP request as well as the “Content-Type” header to “application/json”.
-
Initializes a new JSON HTTP body which ought to encode the given value in the request body.
Declaration
Swift
public init(_ value: T, encoder: JSONEncoder? = nil)
Parameters
value
The value to put into the request body.
encoder
The JSON encoder to use for encoding. When set to
nil
, a JSON encoder is used where camel case attribute names are converted into snake case.
-
Declaration
Swift
public func add(to request: inout URLRequest) throws
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public static func == (lhs: `Self`, rhs: `Self`) -> Bool
-
Declaration
Swift
public func hash(into hasher: inout Hasher)