Example usage for com.fasterxml.jackson.core ObjectCodec readValue

List of usage examples for com.fasterxml.jackson.core ObjectCodec readValue

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core ObjectCodec readValue.

Prototype

public abstract <T> T readValue(JsonParser jp, ResolvedType valueType)
        throws IOException, JsonProcessingException;

Source Link

Document

Method to deserialize JSON content into a POJO, type specified with fully resolved type object (so it can be a generic type, including containers like java.util.Collection and java.util.Map ).

Usage

From source file:org.apache.druid.query.aggregation.AggregationTestHelper.java

private List readQueryResultArrayFromString(String str) throws Exception {
    List result = new ArrayList();

    JsonParser jp = mapper.getFactory().createParser(str);

    if (jp.nextToken() != JsonToken.START_ARRAY) {
        throw new IAE("not an array [%s]", str);
    }/*from  ww w.  jav  a2  s .  c om*/

    ObjectCodec objectCodec = jp.getCodec();

    while (jp.nextToken() != JsonToken.END_ARRAY) {
        result.add(objectCodec.readValue(jp, toolChest.getResultTypeReference()));
    }
    return result;
}