docs/Classes/JSONParameterEncoder.html
open class JSONParameterEncoder : @unchecked Sendable, ParameterEncoder
A ParameterEncoder that encodes types as JSON body data.
If no Content-Type header is already set on the provided URLRequests, it’s set to application/json.
`
default
`
Returns an encoder with default parameters.
Swift
public static var `default`: JSONParameterEncoder { get }
`
prettyPrinted
`
Returns an encoder with JSONEncoder.outputFormatting set to .prettyPrinted.
Swift
public static var prettyPrinted: JSONParameterEncoder { get }
`
sortedKeys
`
Returns an encoder with JSONEncoder.outputFormatting set to .sortedKeys.
Swift
@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)
public static var sortedKeys: JSONParameterEncoder { get }
`
encoder
`
JSONEncoder used to encode parameters.
Swift
public let encoder: JSONEncoder
`
init(encoder:)
`
Creates an instance with the provided JSONEncoder.
Swift
public init(encoder: JSONEncoder = JSONEncoder())
| encoder |
The JSONEncoder. JSONEncoder() by default.
|
`
encode(_:into:)
`
Swift
open func encode<Parameters: Encodable>(_ parameters: Parameters?,
into request: URLRequest) throws -> URLRequest