List of usage examples for com.fasterxml.jackson.core JsonProcessingException printStackTrace
public void printStackTrace()
From source file:cn.designthoughts.sample.axon.sfav.query.customer.controller.QueryCustomerController.java
@RequestMapping(value = "/rest/customers/{customerId}", method = RequestMethod.GET) public String getCustomer(@PathVariable String customerId) { CustomerEntry customer = customerEntryRepository.findByIdentifier(customerId); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); String customerString = ""; try {/*from ww w .j a va2s. c om*/ customerString = mapper.writeValueAsString(customer); } catch (JsonProcessingException e) { e.printStackTrace(); } return customerString; }
From source file:com.parworks.androidlibrary.ar.AugmentedData.java
public String toString() { String res = null;// w w w .j a va 2 s . c o m try { res = mapper.writeValueAsString(this); } catch (JsonProcessingException e) { e.printStackTrace(); } return res; }
From source file:org.wikidata.wdtk.datamodel.json.jackson.AliasesDeserializer.java
@Override public Map<String, List<JacksonMonolingualTextValue>> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Map<String, List<JacksonMonolingualTextValue>> contents = new HashMap<>(); try {/*from w ww . ja va2 s . c o m*/ JsonNode node = jp.getCodec().readTree(jp); if (!node.isArray()) { Iterator<Entry<String, JsonNode>> nodeIterator = node.fields(); while (nodeIterator.hasNext()) { List<JacksonMonolingualTextValue> mltvList = new ArrayList<>(); Entry<String, JsonNode> currentNode = nodeIterator.next(); // get the list of MLTVs Iterator<JsonNode> mltvListIterator = currentNode.getValue().iterator(); while (mltvListIterator.hasNext()) { JsonNode mltvEntry = mltvListIterator.next(); String language = mltvEntry.get("language").asText(); String value = mltvEntry.get("value").asText(); mltvList.add(new JacksonMonolingualTextValue(language, value)); } contents.put(currentNode.getKey(), mltvList); } } } catch (JsonProcessingException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return contents; }
From source file:com.messagehub.samples.env.MessageList.java
/** * Build message list dependent on the format Message Hub requires. The * message list is in the form: [{ "value": string, "time": timestamp }, ...] * /* www . j a v a2 s. c o m*/ * @return {String} String representation of a JSON object. */ @Override public String toString() { try { return new ObjectMapper().writeValueAsString(messages); } catch (final JsonProcessingException e) { e.printStackTrace(); return ""; } }
From source file:com.walmart.gatling.AbstractRestIntTest.java
protected String toJson(Object obj) { try {/*from ww w . j a v a2s . c o m*/ return mapper.writeValueAsString(obj); } catch (JsonProcessingException e) { e.printStackTrace(); throw new RuntimeException("Error marshalling object '" + obj + "' to json string.", e); } }
From source file:com.amazon.services.awsrum.redshift.KinesisMessageModelRedshiftTransformer.java
@Override public String toDelimitedString(KinesisMessageModel record) { String str = ""; try {/* w w w .j av a2s .c o m*/ str = IOUtils.toString(mapper.writer(schema).writeValueAsBytes(record), "UTF-8"); } catch (JsonProcessingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //System.out.println("csv: "+str); return str; }
From source file:EntityProvider.java
private String toJSON(E entity) { String json = null;/*w w w . java 2 s.c o m*/ ObjectifyJacksonModule ojm = new ObjectifyJacksonModule(); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(ojm); try { json = mapper.writeValueAsString(entity); } catch (JsonProcessingException jpe) { jpe.printStackTrace(); } logger.info("Serializing '" + json + "'."); return json; }
From source file:ch.icclab.cyclops.resource.impl.RateStatusResource.java
/** * Build the static rate of a resource/* w ww. j a v a 2 s. c om*/ * * Pseudo Code * 1. Get the latest static rates from a list * 2. Construct the response * 3. Return the json string * * @return Representation */ private Representation buildStaticRateResponse() { String jsonStr = null; RateStatusResponse response = new RateStatusResponse(); ObjectMapper mapper = new ObjectMapper(); response.setRate_policy("static"); response.setRate(Load.getStaticRate()); try { jsonStr = mapper.writeValueAsString(response); } catch (JsonProcessingException e) { e.printStackTrace(); } JsonRepresentation jsonResp = new JsonRepresentation(jsonStr); return jsonResp; }
From source file:ch.icclab.cyclops.resource.impl.RateStatusResource.java
/** * Build the dynamic rate status response * * Pseudo Code// ww w. java2s . c o m * 1. Set the rating policy as dynamic and construct the response * 2. Return the response json string * * @return Representation */ private Representation buildDynamicRateResponse() { String jsonStr = null; RateStatusResponse response = new RateStatusResponse(); ObjectMapper mapper = new ObjectMapper(); response.setRate_policy("dynamic"); response.setRate(null); try { jsonStr = mapper.writeValueAsString(response); } catch (JsonProcessingException e) { e.printStackTrace(); } JsonRepresentation jsonResp = new JsonRepresentation(jsonStr); return jsonResp; }
From source file:org.gameontext.regsvc.db.RegistrationRepository.java
public String getRegistrations() { try {/*from www. j av a2s . c o m*/ return mapper.writeValueAsString(registrations.getRegistrations()); } catch (JsonProcessingException e) { // TODO Auto-generated catch block e.printStackTrace(); return "{}"; } }