Json

public struct Json<T> : HttpBody where T : Encodable
extension HttpData.Json: Equatable where T: Equatable
extension HttpData.Json: Hashable where T: Hashable

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”.

Initialization

  • 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.

HttpBody

  • Declaration

    Swift

    public func add(to request: inout URLRequest) throws
  • Declaration

    Swift

    public var description: String { get }

Available where T: Equatable

  • Declaration

    Swift

    public static func == (lhs: `Self`, rhs: `Self`) -> Bool

Available where T: Hashable

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)