Search in sources :

Example 16 with JsonParser

use of org.codehaus.jackson.JsonParser in project OpenRefine by OpenRefine.

the class Recon method loadStreaming.

public static Recon loadStreaming(String s, Pool pool) throws Exception {
    JsonFactory jsonFactory = new JsonFactory();
    JsonParser jp = jsonFactory.createJsonParser(s);
    if (jp.nextToken() != JsonToken.START_OBJECT) {
        return null;
    }
    return loadStreaming(jp, pool);
}
Also used : JsonFactory(org.codehaus.jackson.JsonFactory) JsonParser(org.codehaus.jackson.JsonParser)

Example 17 with JsonParser

use of org.codehaus.jackson.JsonParser in project OpenRefine by OpenRefine.

the class ReconCandidate method loadStreaming.

public static ReconCandidate loadStreaming(String s) throws Exception {
    JsonFactory jsonFactory = new JsonFactory();
    JsonParser jp = jsonFactory.createJsonParser(s);
    if (jp.nextToken() != JsonToken.START_OBJECT) {
        return null;
    }
    return loadStreaming(jp);
}
Also used : JsonFactory(org.codehaus.jackson.JsonFactory) JsonParser(org.codehaus.jackson.JsonParser)

Example 18 with JsonParser

use of org.codehaus.jackson.JsonParser in project spring-data-document-examples by spring-projects.

the class CouchDbMappingJacksonHttpMessageConverter method success.

private Object success(Class<?> clazz, HttpInputMessage inputMessage) throws JsonParseException, IOException {
    //Note, parsing code used from ektorp project
    JsonParser jp = objectMapper.getJsonFactory().createJsonParser(inputMessage.getBody());
    if (jp.nextToken() != JsonToken.START_OBJECT) {
        throw new RuntimeException("Expected data to start with an Object");
    }
    Map<String, Integer> fields = readHeaderFields(jp);
    List result;
    if (fields.containsKey(TOTAL_ROWS_FIELD_NAME)) {
        int totalRows = fields.get(TOTAL_ROWS_FIELD_NAME);
        if (totalRows == 0) {
            return Collections.emptyList();
        }
        result = new ArrayList(totalRows);
    } else {
        result = new ArrayList();
    }
    ParseState state = new ParseState();
    Object first = parseFirstRow(jp, state, clazz);
    if (first == null) {
        return Collections.emptyList();
    } else {
        result.add(first);
    }
    while (jp.getCurrentToken() != null) {
        skipToField(jp, state.docFieldName, state);
        if (atEndOfRows(jp)) {
            return result;
        }
        result.add(jp.readValueAs(clazz));
        endRow(jp, state);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JsonParser(org.codehaus.jackson.JsonParser)

Example 19 with JsonParser

use of org.codehaus.jackson.JsonParser in project zaproxy by zaproxy.

the class HarUtils method createHarRequest.

public static HarRequest createHarRequest(String jsonHarRequest) throws IOException {
    HarRequest harRequest;
    try (JsonParser jp = new JsonFactory().createJsonParser(jsonHarRequest)) {
        jp.nextToken();
        jp.nextToken();
        harRequest = new HarRequest(jp, null);
    }
    return harRequest;
}
Also used : HarRequest(edu.umass.cs.benchlab.har.HarRequest) JsonFactory(org.codehaus.jackson.JsonFactory) JsonParser(org.codehaus.jackson.JsonParser)

Example 20 with JsonParser

use of org.codehaus.jackson.JsonParser in project flink by apache.

the class DumpCompiledPlanTest method dump.

private void dump(Plan p) {
    p.setExecutionConfig(new ExecutionConfig());
    try {
        OptimizedPlan op = compileNoStats(p);
        PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator();
        String json = dumper.getOptimizerPlanAsJSON(op);
        JsonParser parser = new JsonFactory().createJsonParser(json);
        while (parser.nextToken() != null) ;
    } catch (JsonParseException e) {
        e.printStackTrace();
        Assert.fail("JSON Generator produced malformatted output: " + e.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("An error occurred in the test: " + e.getMessage());
    }
}
Also used : PlanJSONDumpGenerator(org.apache.flink.optimizer.plandump.PlanJSONDumpGenerator) JsonFactory(org.codehaus.jackson.JsonFactory) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) JsonParseException(org.codehaus.jackson.JsonParseException) JsonParseException(org.codehaus.jackson.JsonParseException) OptimizedPlan(org.apache.flink.optimizer.plan.OptimizedPlan) JsonParser(org.codehaus.jackson.JsonParser)

Aggregations

JsonParser (org.codehaus.jackson.JsonParser)21 JsonFactory (org.codehaus.jackson.JsonFactory)13 IOException (java.io.IOException)6 JsonParseException (org.codehaus.jackson.JsonParseException)5 ArrayList (java.util.ArrayList)4 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)4 List (java.util.List)3 GwtTestException (com.googlecode.gwt.test.exceptions.GwtTestException)2 GwtTestJSONException (com.googlecode.gwt.test.exceptions.GwtTestJSONException)2 File (java.io.File)2 Map (java.util.Map)2 PlanJSONDumpGenerator (org.apache.flink.optimizer.plandump.PlanJSONDumpGenerator)2 JsonNode (org.codehaus.jackson.JsonNode)2 JsonToken (org.codehaus.jackson.JsonToken)2 TypeReference (org.codehaus.jackson.type.TypeReference)2 Message (com.amazonaws.services.sqs.model.Message)1 ReceiveMessageRequest (com.amazonaws.services.sqs.model.ReceiveMessageRequest)1 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)1 HarRequest (edu.umass.cs.benchlab.har.HarRequest)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1