Search in sources :

Example 1 with SerializationException

use of kotlinx.serialization.SerializationException in project spring-framework by spring-projects.

the class KotlinSerializationJsonHttpMessageConverter method decode.

private Object decode(KSerializer<Object> serializer, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
    MediaType contentType = inputMessage.getHeaders().getContentType();
    String jsonText = StreamUtils.copyToString(inputMessage.getBody(), getCharsetToUse(contentType));
    try {
        // TODO Use stream based API when available
        return this.json.decodeFromString(serializer, jsonText);
    } catch (SerializationException ex) {
        throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex, inputMessage);
    }
}
Also used : SerializationException(kotlinx.serialization.SerializationException) HttpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException) MediaType(org.springframework.http.MediaType)

Aggregations

SerializationException (kotlinx.serialization.SerializationException)1 MediaType (org.springframework.http.MediaType)1 HttpMessageNotReadableException (org.springframework.http.converter.HttpMessageNotReadableException)1