Search in sources :

Example 16 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project pinpoint by naver.

the class ObjectMapperIT method testConstructor.

@Test
public void testConstructor() throws Exception {
    ObjectMapper mapper1 = new ObjectMapper();
    ObjectMapper mapper2 = new ObjectMapper(new JsonFactory());
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Constructor<?> omConstructor = ObjectMapper.class.getConstructor(JsonFactory.class, DefaultSerializerProvider.class, DefaultDeserializationContext.class);
    Constructor<?> omConstructor1 = ObjectMapper.class.getConstructor();
    Constructor<?> omConstructor2 = ObjectMapper.class.getConstructor(JsonFactory.class);
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor1));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor2));
    verifier.verifyTraceCount(0);
}
Also used : JsonFactory(com.fasterxml.jackson.core.JsonFactory) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 17 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project openhab1-addons by openhab.

the class JsonWeatherParser method parseInto.

/**
     * {@inheritDoc}
     */
@Override
public void parseInto(InputStream is, Weather weather) throws Exception {
    JsonFactory jsonFactory = new JsonFactory();
    JsonParser jp = jsonFactory.createParser(is);
    jp.nextValue();
    handleToken(jp, null, weather);
    jp.close();
    super.parseInto(is, weather);
}
Also used : JsonFactory(com.fasterxml.jackson.core.JsonFactory) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 18 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project presto by prestodb.

the class TestJsonExtract method doExtract.

private static String doExtract(JsonExtractor<Slice> jsonExtractor, String json) throws IOException {
    JsonFactory jsonFactory = new JsonFactory();
    JsonParser jsonParser = jsonFactory.createParser(json);
    // Advance to the first token
    jsonParser.nextToken();
    Slice extract = jsonExtractor.extract(jsonParser);
    return (extract == null) ? null : extract.toStringUtf8();
}
Also used : Slice(io.airlift.slice.Slice) JsonFactory(com.fasterxml.jackson.core.JsonFactory) JsonParser(com.fasterxml.jackson.core.JsonParser)

Example 19 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project ratpack by ratpack.

the class DefaultConfigDataBuilder method newDefaultObjectMapper.

public static ObjectMapper newDefaultObjectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    objectMapper.registerModule(new Jdk8Module());
    objectMapper.registerModule(new GuavaModule());
    objectMapper.registerModule(new JavaTimeModule());
    JsonFactory factory = objectMapper.getFactory();
    factory.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
    factory.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
    return objectMapper;
}
Also used : Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) JsonFactory(com.fasterxml.jackson.core.JsonFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GuavaModule(com.fasterxml.jackson.datatype.guava.GuavaModule)

Example 20 with JsonFactory

use of com.fasterxml.jackson.core.JsonFactory in project android-async-http by loopj.

the class CustomCASample method getResponseHandler.

@Override
public ResponseHandlerInterface getResponseHandler() {
    return new BaseJsonHttpResponseHandler<SampleJSON>() {

        @Override
        public void onStart() {
            clearOutputs();
        }

        @Override
        public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, SampleJSON response) {
            debugHeaders(LOG_TAG, headers);
            debugStatusCode(LOG_TAG, statusCode);
            if (response != null) {
                debugResponse(LOG_TAG, rawJsonResponse);
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData, SampleJSON errorResponse) {
            debugHeaders(LOG_TAG, headers);
            debugStatusCode(LOG_TAG, statusCode);
            debugThrowable(LOG_TAG, throwable);
            if (errorResponse != null) {
                debugResponse(LOG_TAG, rawJsonData);
            }
        }

        @Override
        protected SampleJSON parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
            return new ObjectMapper().readValues(new JsonFactory().createParser(rawJsonData), SampleJSON.class).next();
        }
    };
}
Also used : SampleJSON(com.loopj.android.http.sample.util.SampleJSON) JsonFactory(com.fasterxml.jackson.core.JsonFactory) BaseJsonHttpResponseHandler(com.loopj.android.http.BaseJsonHttpResponseHandler) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonFactory (com.fasterxml.jackson.core.JsonFactory)101 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)39 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 Test (org.junit.Test)31 StringWriter (java.io.StringWriter)29 JsonParser (com.fasterxml.jackson.core.JsonParser)24 ExtensibleJSONWriter (com.instagram.common.json.annotation.processor.support.ExtensibleJSONWriter)15 IOException (java.io.IOException)14 Map (java.util.Map)14 HashMap (java.util.HashMap)11 SimpleParseUUT (com.instagram.common.json.annotation.processor.uut.SimpleParseUUT)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 FileInputStream (java.io.FileInputStream)6 ServletOutputStream (javax.servlet.ServletOutputStream)6 Reader (java.io.Reader)5 RemoteSession (org.apache.jackrabbit.oak.remote.RemoteSession)5 File (java.io.File)4 JSONWriter (org.json.JSONWriter)4 BaseJsonHttpResponseHandler (com.loopj.android.http.BaseJsonHttpResponseHandler)3