use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project Fast-Android-Networking by amitshekhariitbhu.
the class JacksonParserFactory method getObject.
@Override
public Object getObject(String string, Type type) {
try {
JavaType javaType = mapper.getTypeFactory().constructType(type);
ObjectReader objectReader = mapper.readerFor(javaType);
return objectReader.readValue(string);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project drill by apache.
the class TestParsePhysicalPlan method parseSimplePlan.
@Test
public void parseSimplePlan() throws Exception {
DrillConfig c = DrillConfig.create();
ScanResult scanResult = ClassPathScanner.fromPrescan(c);
LogicalPlanPersistence lpp = new LogicalPlanPersistence(c, scanResult);
PhysicalPlanReader reader = new PhysicalPlanReader(c, scanResult, lpp, CoordinationProtos.DrillbitEndpoint.getDefaultInstance(), null);
ObjectReader r = lpp.getMapper().reader(PhysicalPlan.class);
ObjectWriter writer = lpp.getMapper().writer();
PhysicalPlan plan = reader.readPhysicalPlan(Files.asCharSource(DrillFileUtils.getResourceAsFile("/physical_test1.json"), Charsets.UTF_8).read());
plan.unparse(writer);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project dhis2-core by dhis2.
the class TrackerCsvEventService method readEvents.
@Override
public List<Event> readEvents(InputStream inputStream, boolean skipFirst) throws IOException, ParseException {
final CsvSchema csvSchema = CSV_MAPPER.schemaFor(CsvEventDataValue.class).withUseHeader(skipFirst).withColumnReordering(true);
List<Event> events = Lists.newArrayList();
ObjectReader reader = CSV_MAPPER.readerFor(CsvEventDataValue.class).with(csvSchema);
MappingIterator<CsvEventDataValue> iterator = reader.readValues(inputStream);
Event event = new Event();
while (iterator.hasNext()) {
CsvEventDataValue dataValue = iterator.next();
if (!Objects.equals(event.getEvent(), dataValue.getEvent())) {
event = new Event();
event.setEvent(dataValue.getEvent());
event.setStatus(StringUtils.isEmpty(dataValue.getStatus()) ? EventStatus.ACTIVE : Enum.valueOf(EventStatus.class, dataValue.getStatus()));
event.setProgram(dataValue.getProgram());
event.setProgramStage(dataValue.getProgramStage());
event.setEnrollment(dataValue.getEnrollment());
event.setOrgUnit(dataValue.getOrgUnit());
event.setCreatedAt(DateUtils.instantFromDateAsString(dataValue.getCreatedAt()));
event.setCreatedAtClient(DateUtils.instantFromDateAsString(dataValue.getCreatedAtClient()));
event.setUpdatedAt(DateUtils.instantFromDateAsString(dataValue.getUpdatedAt()));
event.setUpdatedAtClient(DateUtils.instantFromDateAsString(dataValue.getUpdatedAtClient()));
event.setOccurredAt(DateUtils.instantFromDateAsString(dataValue.getOccurredAt()));
event.setScheduledAt(DateUtils.instantFromDateAsString(dataValue.getScheduledAt()));
event.setCompletedAt(DateUtils.instantFromDateAsString(dataValue.getCompletedAt()));
event.setCompletedBy(dataValue.getCompletedBy());
event.setStoredBy(dataValue.getStoredBy());
event.setAttributeOptionCombo(dataValue.getAttributeOptionCombo());
event.setAttributeCategoryOptions(dataValue.getAttributeCategoryOptions());
event.setAssignedUser(dataValue.getAssignedUser());
if (dataValue.getGeometry() != null) {
event.setGeometry(new WKTReader().read(dataValue.getGeometry()));
} else if (dataValue.getLongitude() != null && dataValue.getLatitude() != null) {
event.setGeometry(new WKTReader().read("Point(" + dataValue.getLongitude() + " " + dataValue.getLatitude() + ")"));
}
events.add(event);
}
if (ObjectUtils.anyNotNull(dataValue.getProvidedElsewhere(), dataValue.getDataElement(), dataValue.getValue(), dataValue.getCreatedAtDataValue(), dataValue.getUpdatedAtDataValue(), dataValue.getStoredByDataValue())) {
DataValue value = new DataValue();
value.setProvidedElsewhere(dataValue.getProvidedElsewhere() != null && dataValue.getProvidedElsewhere());
value.setDataElement(dataValue.getDataElement());
value.setValue(dataValue.getValue());
value.setCreatedAt(DateUtils.instantFromDateAsString(dataValue.getCreatedAtDataValue()));
value.setUpdatedAt(DateUtils.instantFromDateAsString(dataValue.getUpdatedAtDataValue()));
value.setStoredBy(dataValue.getStoredByDataValue());
event.getDataValues().add(value);
}
}
return events;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project swagger-core by swagger-api.
the class ParameterDeserializer method deserialize.
@Override
public Parameter deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
Parameter result = null;
JsonNode node = jp.getCodec().readTree(jp);
JsonNode sub = node.get("$ref");
JsonNode inNode = node.get("in");
JsonNode desc = node.get("description");
if (sub != null) {
result = new Parameter().$ref(sub.asText());
if (desc != null && openapi31) {
result.description(desc.asText());
}
} else if (inNode != null) {
String in = inNode.asText();
ObjectReader reader = null;
ObjectMapper mapper = null;
if (openapi31) {
mapper = Json31.mapper();
} else {
mapper = Json.mapper();
}
if ("query".equals(in)) {
reader = mapper.readerFor(QueryParameter.class);
} else if ("header".equals(in)) {
reader = mapper.readerFor(HeaderParameter.class);
} else if ("path".equals(in)) {
reader = mapper.readerFor(PathParameter.class);
} else if ("cookie".equals(in)) {
reader = mapper.readerFor(CookieParameter.class);
}
if (reader != null) {
result = reader.with(DeserializationFeature.READ_ENUMS_USING_TO_STRING).readValue(node);
}
}
return result;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project fdroidclient by f-droid.
the class IndexV1UpdaterTest method parseRepo.
private Repo parseRepo(ObjectMapper mapper, JsonParser parser) throws IOException {
parser.nextToken();
parser.nextToken();
ObjectReader repoReader = mapper.readerFor(Repo.class);
return repoReader.readValue(parser, Repo.class);
}
Aggregations