use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project yorc-a4c-plugin by ystia.
the class RestClient method initObjectMapper.
private static void initObjectMapper() {
RestClient.objectMapper = new ObjectMapper() {
private com.fasterxml.jackson.databind.ObjectMapper jacksonObjectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
public <T> T readValue(String value, Class<T> valueType) {
try {
return jacksonObjectMapper.readValue(value, valueType);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String writeValue(Object value) {
try {
return jacksonObjectMapper.writeValueAsString(value);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
};
Unirest.setObjectMapper(RestClient.objectMapper);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project loinc2hpo by monarch-initiative.
the class WriteToFile method toJson.
public static void toJson(Map<LoincId, UniversalLoinc2HPOAnnotation> annotationMap) {
ObjectMapper mapper = new ObjectMapper();
annotationMap.entrySet().forEach(p -> {
try {
System.out.println(mapper.writeValueAsString(p));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
});
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project swagger-parser by swagger-api.
the class OpenAPIV3Parser method readContents.
private SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options, String location) {
if (swaggerAsString == null || swaggerAsString.trim().isEmpty()) {
return SwaggerParseResult.ofError("Null or empty definition");
}
try {
final ObjectMapper mapper = getRightMapper(swaggerAsString);
JsonNode rootNode;
final SwaggerParseResult deserializationUtilsResult = new SwaggerParseResult();
if (options != null && options.isLegacyYamlDeserialization()) {
rootNode = mapper.readTree(swaggerAsString);
} else {
try {
rootNode = DeserializationUtils.deserializeIntoTree(swaggerAsString, location, options, deserializationUtilsResult);
} catch (Exception e) {
rootNode = mapper.readTree(swaggerAsString);
}
}
SwaggerParseResult result;
if (options != null) {
result = parseJsonNode(location, rootNode, options);
} else {
result = parseJsonNode(location, rootNode);
}
if (result.getOpenAPI() != null) {
result = resolve(result, auth, options, location);
}
if (deserializationUtilsResult.getMessages() != null) {
for (String s : deserializationUtilsResult.getMessages()) {
result.message(getParseErrorMessage(s, location));
}
}
return result;
} catch (JsonProcessingException e) {
LOGGER.warn("Exception while parsing:", e);
final String message = getParseErrorMessage(e.getOriginalMessage(), location);
return SwaggerParseResult.ofError(message);
} catch (Exception e) {
LOGGER.warn("Exception while parsing:", e);
final String message = getParseErrorMessage(e.getMessage(), location);
return SwaggerParseResult.ofError(message);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project UVMS-ActivityModule-APP by UnionVMS.
the class FACatchSummaryHelper method printJsonstructure.
public static String printJsonstructure(Object obj) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
String s = null;
try {
s = mapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
log.error("Exception while parsing JSON", e);
}
log.debug("json structure:-------->");
log.debug("" + s);
return s;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project UVMS-ActivityModule-APP by UnionVMS.
the class JacksonSubclassSerializerTest method testSerializing.
@SneakyThrows
@Test
public void testSerializing() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
FishingActivityQuery fishQuery = new FishingActivityQuery();
Map<SearchFilter, String> map = new HashMap<>();
String val = "someVal";
map.put(SearchFilter.VESSEL, val);
fishQuery.setSearchCriteriaMap(map);
String s = null;
try {
s = mapper.writeValueAsString(fishQuery);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
System.out.println(s);
}
Aggregations