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);
}
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);
}
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;
}
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;
}
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());
}
}
Aggregations