Search in sources :

Example 6 with UnableToProduceResultException

use of org.jdbi.v3.core.result.UnableToProduceResultException in project jdbi by jdbi.

the class JacksonJsonMapper method fromJson.

@Override
public Object fromJson(Type type, String json, ConfigRegistry config) {
    try {
        Jackson2Config cfg = config.get(Jackson2Config.class);
        ObjectReader reader = cfg.getMapper().readerFor(cfg.getMapper().constructType(type));
        Class<?> view = cfg.getDeserializationView();
        if (view != null) {
            reader = reader.withView(view);
        }
        return reader.readValue(json);
    } catch (IOException e) {
        throw new UnableToProduceResultException(e);
    }
}
Also used : ObjectReader(com.fasterxml.jackson.databind.ObjectReader) IOException(java.io.IOException) UnableToProduceResultException(org.jdbi.v3.core.result.UnableToProduceResultException)

Aggregations

ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 UnableToProduceResultException (org.jdbi.v3.core.result.UnableToProduceResultException)3 RowViewImpl (org.jdbi.v3.core.result.internal.RowViewImpl)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 IOException (java.io.IOException)1 ColumnMappers (org.jdbi.v3.core.mapper.ColumnMappers)1 EncodedJson (org.jdbi.v3.json.EncodedJson)1 JsonConfig (org.jdbi.v3.json.JsonConfig)1 JsonMapper (org.jdbi.v3.json.JsonMapper)1