RequestBody

public protocol RequestBody : Encodable, Sendable

A protocol for request bodies that should be JSON encoded before sending.

  • jsonData Default implementation

    A JSON representation of the request body.

    Default Implementation

    Declaration

    Swift

    @available(*, deprecated, message: "Use getJsonData(﹚ instead. This property uses force-try and will crash if encoding fails (e.g., with NaN or infinity values﹚")
    var jsonData: Data { get }
  • getJsonData() Default implementation

    Encodes the request body as JSON using Bagbutik’s default encoder configuration.

    Throws

    An error if encoding fails, for example because the body contains NaN or infinity values.

    Default Implementation

    Encodes the request body as JSON using ISO 8601 dates.

    Throws

    An error if encoding fails, for example because the body contains NaN or infinity values.

    Declaration

    Swift

    func getJsonData() throws -> Data