Contents

encode(_:)

Returns a JSON-encoded representation of the value you supply.

Declaration

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

Parameters

  • value:

    The value to encode as JSON.

Return Value

The encoded JSON data.

Discussion

If there’s a problem encoding the value you supply, this method throws an error based on the type of problem:

See Also

First Steps