ExtendedJSONEncoder

public class ExtendedJSONEncoder
extension ExtendedJSONEncoder: ContentEncoder

Facilitates the encoding of Encodable values into ExtendedJSON.

  • A struct representing the supported string formats based on the JSON standard that describe how to represent BSON documents in JSON using standard JSON types and/or type wrapper objects.

    See more

    Declaration

    Swift

    public struct Format
  • Determines whether to encode to canonical or relaxed extended JSON. Default is relaxed.

    Declaration

    Swift

    public var format: Format
  • Contextual user-provided information for use during encoding.

    Declaration

    Swift

    public var userInfo: [CodingUserInfoKey : Any]
  • Initialize an ExtendedJSONEncoder.

    Declaration

    Swift

    public init()
  • Encodes an instance of the Encodable Type T into Data representing canonical or relaxed extended JSON. The value of self.format will determine which format is used. If it is not set explicitly, relaxed will be used.

    Throws

    EncodingError if the value is corrupt or cannot be converted to valid ExtendedJSON.

    Declaration

    Swift

    public func encode<T>(_ value: T) throws -> Data where T : Encodable

    Parameters

    value

    instance of Encodable type T which will be encoded.

    Return Value

    Encoded representation of the T input as an instance of Data representing ExtendedJSON.

  • Encodes an instance of the Encodable Type T into a ByteBuffer representing canonical or relaxed extended JSON. The value of self.format will determine which format is used. If it is not set explicitly, relaxed will be used.

    Throws

    EncodingError if the value is corrupt or cannot be converted to valid ExtendedJSON.

    Declaration

    Swift

    public func encodeBuffer<T>(_ value: T) throws -> ByteBuffer where T : Encodable

    Parameters

    value

    instance of Encodable type T which will be encoded.

    Return Value

    Encoded representation of the T input as an instance of ByteBuffer representing ExtendedJSON.

  • Declaration

    Swift

    public func encode<E>(_ encodable: E, to body: inout ByteBuffer, headers: inout HTTPHeaders) throws
        where E: Encodable