Search in sources :

Example 6 with JsonParser

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project rest.li by linkedin.

the class JacksonDataCodec method bytesToList.

@Override
public DataList bytesToList(byte[] input) throws IOException {
    final Parser parser = new Parser();
    JsonParser jsonParser = null;
    try {
        jsonParser = _jsonFactory.createParser(input);
        return parser.parse(jsonParser, DataList.class);
    } catch (IOException e) {
        throw e;
    } finally {
        closeJsonParserQuietly(jsonParser);
    }
}
Also used : IOException(java.io.IOException) JsonParser(com.fasterxml.jackson.core.JsonParser) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 7 with JsonParser

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project rest.li by linkedin.

the class JacksonDataCodec method readMap.

@Override
public DataMap readMap(InputStream in) throws IOException {
    final Parser parser = new Parser();
    JsonParser jsonParser = null;
    try {
        jsonParser = _jsonFactory.createParser(in);
        return parser.parse(jsonParser, DataMap.class);
    } catch (IOException e) {
        throw e;
    } finally {
        closeJsonParserQuietly(jsonParser);
    }
}
Also used : IOException(java.io.IOException) JsonParser(com.fasterxml.jackson.core.JsonParser) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 8 with JsonParser

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project rest.li by linkedin.

the class JacksonDataCodec method bytesToMap.

@Override
public DataMap bytesToMap(byte[] input) throws IOException {
    final Parser parser = new Parser();
    JsonParser jsonParser = null;
    try {
        jsonParser = _jsonFactory.createParser(input);
        return parser.parse(jsonParser, DataMap.class);
    } catch (IOException e) {
        throw e;
    } finally {
        closeJsonParserQuietly(jsonParser);
    }
}
Also used : IOException(java.io.IOException) JsonParser(com.fasterxml.jackson.core.JsonParser) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 9 with JsonParser

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project immutables by immutables.

the class BsonEncoding method unwrapJsonable.

public static DBObject unwrapJsonable(String json) {
    try {
        JsonParser parser = JSON_FACTORY.createParser(json);
        parser.nextToken();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        BsonGenerator generator = BSON_FACTORY.createGenerator(outputStream);
        generator.copyCurrentStructure(parser);
        generator.close();
        parser.close();
        byte[] data = outputStream.toByteArray();
        return (DBObject) new LazyDBCallback(null).createObject(data, 0);
    } catch (IOException ex) {
        throw Throwables.propagate(ex);
    }
}
Also used : BsonGenerator(de.undercouch.bson4jackson.BsonGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) LazyDBCallback(com.mongodb.LazyDBCallback) DBObject(com.mongodb.DBObject) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 10 with JsonParser

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project hadoop by apache.

the class StatePool method read.

private void read(DataInput in) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    // define a module
    SimpleModule module = new SimpleModule("State Serializer", new Version(0, 1, 1, "FINAL", "", ""));
    // add the state deserializer
    module.addDeserializer(StatePair.class, new StateDeserializer());
    // register the module with the object-mapper
    mapper.registerModule(module);
    JsonParser parser = mapper.getFactory().createParser((DataInputStream) in);
    StatePool statePool = mapper.readValue(parser, StatePool.class);
    this.setStates(statePool.getStates());
    parser.close();
}
Also used : Version(com.fasterxml.jackson.core.Version) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) JsonParser(com.fasterxml.jackson.core.JsonParser)

Aggregations

JsonParser (com.fasterxml.jackson.core.JsonParser)587 KriptonRuntimeException (com.abubusoft.kripton.exception.KriptonRuntimeException)258 JacksonWrapperParser (com.abubusoft.kripton.persistence.JacksonWrapperParser)258 KriptonJsonContext (com.abubusoft.kripton.KriptonJsonContext)257 ArrayList (java.util.ArrayList)171 IOException (java.io.IOException)126 JsonFactory (com.fasterxml.jackson.core.JsonFactory)76 Test (org.junit.Test)57 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)51 JsonNode (com.fasterxml.jackson.databind.JsonNode)46 HashSet (java.util.HashSet)43 JsonToken (com.fasterxml.jackson.core.JsonToken)41 LinkedHashSet (java.util.LinkedHashSet)38 HashMap (java.util.HashMap)35 LinkedList (java.util.LinkedList)26 JsonParseException (com.fasterxml.jackson.core.JsonParseException)23 JsonUtil.createJsonParser (com.facebook.presto.util.JsonUtil.createJsonParser)21 List (java.util.List)21 DeserializationContext (com.fasterxml.jackson.databind.DeserializationContext)20 InputStream (java.io.InputStream)20