List of usage examples for com.fasterxml.jackson.core JsonProcessingException getMessage
@Override
public String getMessage()
From source file:com.hybridbpm.ui.component.chart.util.DiagrammeUtil.java
public static String objectToString(Object object) { try {//w w w. j a v a 2 s. com ObjectMapper mapper = new ObjectMapper(); // mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); return mapper.writeValueAsString(object); } catch (JsonProcessingException ex) { LOG.log(Level.SEVERE, ex.getMessage(), ex); } return new String(); }
From source file:test.LocationCrawler.java
public static String getLocationCoord(String Address) { String jsonString = ProcessLocationRequest(Address); String LocationCoord = ""; if (jsonString.length() > 0) { try {//from w ww . j a v a 2 s. com ObjectMapper m = new ObjectMapper(); JsonNode rootNode = m.readTree(jsonString); for (JsonNode result : rootNode.path("results")) { JsonNode LatLongNode = result.path("geometry").path("location"); LocationCoord = String.format("%s|%s", LatLongNode.path("lat").doubleValue(), LatLongNode.path("lng").doubleValue()); break; } } catch (JsonProcessingException jpe) { System.out.println(jpe.getMessage()); } catch (IOException ioe) { System.out.println(ioe.getMessage()); } catch (Exception e) { System.out.println(e.getMessage()); } finally { return LocationCoord; } } else { return LocationCoord; } }
From source file:io.getlime.push.repository.serialization.JSONSerialization.java
/** * Method used for parsing message into JSON. * * @param message string Message to be serialized. * @return JSON containing the message contents. */// w w w . j a v a2 s . com public static String serializePushMessageBody(PushMessageBody message) throws PushServerException { String messageString; try { messageString = new ObjectMapper().writeValueAsString(message); } catch (JsonProcessingException e) { Logger.getLogger(PushCampaignController.class.getName()).log(Level.SEVERE, e.getMessage(), e); throw new PushServerException("Failed parsing into JSON"); } return messageString; }
From source file:org.talend.dataquality.semantic.classifier.custom.UDCategorySerDeser.java
static UserDefinedClassifier readJsonFile(InputStream inputStream) throws IOException { try {// w ww. j a va2 s . c o m return new ObjectMapper().readValue(inputStream, UserDefinedClassifier.class); } catch (JsonProcessingException e) { LOGGER.error(e.getMessage(), e); return null; } }
From source file:org.talend.dataquality.semantic.classifier.custom.UDCategorySerDeser.java
static UserDefinedClassifier readJsonFile(String content) throws IOException { try {/*from w w w . jav a 2 s . c o m*/ return new ObjectMapper().readValue(content, UserDefinedClassifier.class); } catch (JsonProcessingException e) { LOGGER.error(e.getMessage(), e); return null; } }
From source file:org.wso2.carbon.das.messageflow.data.publisher.publish.ConfigurationPublisher.java
private static void addEventData(Object[] eventData, StructuringArtifact structuringArtifact) { /* [0] -> hashcode */ eventData[0] = String.valueOf(structuringArtifact.getHashcode()); /* [1] -> entryName */ eventData[1] = String.valueOf(structuringArtifact.getName()); ArrayList<StructuringElement> elementList = structuringArtifact.getList(); String jsonString = null;// w ww.j ava2 s . c o m try { jsonString = mapper.writeValueAsString(elementList); } catch (JsonProcessingException e) { log.error("Error while reading input stream. " + e.getMessage()); } /* [2] -> configData */ eventData[2] = jsonString; }
From source file:de.thingweb.util.encoding.ContentHelper.java
public static String wrapJson(Object content) { String json;//from w ww .j a v a 2s . c o m try { json = mapper.writer().writeValueAsString(content); } catch (JsonProcessingException e) { json = "{ \"error\" : \" " + e.getMessage() + "\" , \"input\" : \"" + content.toString() + "\" }"; } return json; }
From source file:com.spotify.styx.api.Middlewares.java
public static Middleware<AsyncHandler<? extends Response<?>>, AsyncHandler<Response<ByteString>>> jsonAsync() { return innerHandler -> innerHandler.map(response -> { if (!response.payload().isPresent()) { // noinspection unchecked return (Response<ByteString>) response; }/*from w w w . ja v a 2s .c o m*/ final Object tPayload = response.payload().get(); try { final byte[] bytes = OBJECT_MAPPER.writeValueAsBytes(tPayload); final ByteString payload = ByteString.of(bytes); return response.withPayload(payload).withHeader("Content-Type", "application/json"); } catch (JsonProcessingException e) { return Response.forStatus(Status.INTERNAL_SERVER_ERROR .withReasonPhrase("Failed to serialize response " + e.getMessage())); } }); }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static String objectToJson(Object obj) { ObjectMapper mapper = new ObjectMapper(); String json;/*from w w w .j ava 2 s . c om*/ try { json = mapper.writeValueAsString(obj); } catch (JsonProcessingException e) { throw new RuntimeException(e.getMessage(), e); } return json; }
From source file:com.vmware.photon.controller.api.frontend.lib.UsageTagHelper.java
public static String serialize(Set<String> usageTags) { if (usageTags == null) { throw new IllegalArgumentException("Null usage tag set cannot be serialized"); }/* ww w. j a v a2 s. c o m*/ try { return objectMapper .writeValueAsString(Ordering.usingToString().natural().immutableSortedCopy(usageTags)); } catch (JsonProcessingException e) { logger.error("Error serializing usageTags set", e); throw new IllegalArgumentException( String.format("Error serializing usageTags set: %s", e.getMessage())); } }