deserialize

inline suspend fun <Success> HttpResponse.deserialize(json: Json): Success

Extension function to deserialize an HTTP response to a specified type.

This function reads the response body as text, checks the status code, and deserializes the response body to the specified type if the status code indicates success. If the status code indicates a client or server error, it throws an appropriate exception.

Return

The deserialized response body as the specified type.

Parameters

json

The JSON serializer instance.

Throws

If the status code is in the 400-499 range.

If the status code is in the 500-599 range.

If the status code is outside the 200-299, 400-499, and 500-599 ranges.