Example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace

List of usage examples for com.fasterxml.jackson.core JsonProcessingException printStackTrace

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:javasnack.snacks.json.PojoEncodeJackson.java

@Override
public void run() {
    ObjectMapper objectMapper = new ObjectMapper();
    try {/*from  w  ww .ja va  2s.c  o  m*/
        String jsonout = objectMapper.writeValueAsString(new EncodePojo());
        System.out.println("--- simple jackson encode ---");
        System.out.println(jsonout);
        String jsonout2 = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(new EncodePojo());
        System.out.println("--- default pretty-print jackson encode ---");
        System.out.println(jsonout2);
        System.out.println("--- streaming jackson encode ---");
        JsonFactory jsonFactory = objectMapper.getFactory();
        Writer out = new OutputStreamWriter(System.out);
        JsonGenerator jg = jsonFactory.createGenerator(out);
        jg.setPrettyPrinter(new DefaultPrettyPrinter());
        jg.writeStartObject();
        jg.writeStringField("message", "success");
        jg.writeNumberField("count", 10);
        jg.writeArrayFieldStart("records");
        for (int i = 0; i < 10; i++) {
            jg.writeObject(new EncodePojo());
            Thread.sleep(100);
            jg.flush();
        }
        jg.writeEndArray();
        jg.writeEndObject();
        jg.close();
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.apache.streams.twitter.serializer.TwitterJsonDeleteActivitySerializer.java

public Activity convert(ObjectNode event) throws ActivitySerializerException {

    ObjectMapper mapper = StreamsTwitterMapper.getInstance();
    Delete delete = null;/*from  ww  w.j a  v  a 2 s .c o m*/
    try {
        delete = mapper.treeToValue(event, Delete.class);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    Activity activity = new Activity();
    updateActivity(delete, activity);
    return activity;
}

From source file:com.pingunaut.wicket.chartjs.core.SimpleChartPanel.java

@Override
public String generateChart() {
    String dataString = null;/*w  w w  .j av  a2 s.  c om*/
    String optionString = null;
    try {
        dataString = getChart().getMapper().writeValueAsString(getChart().getData());
        optionString = getChart().getMapper().writeValueAsString(getChart().getOptions());
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    String js = "var " + getChartCanvas().getMarkupId() + " = WicketCharts['" + getChartCanvas().getMarkupId()
            + "']." + getChart().getClass().getSimpleName() + "(" + dataString + ", " + optionString + ");";
    return js;
}

From source file:org.jplus.hyberbin.excel.json.SimpleJsonUtil.java

@Override
public String toJSON(Object object) {
    try {//from w w w.  j  a  v a 2  s.c  o  m
        return mapper.writeValueAsString(object);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return NULL_STRING;
}

From source file:com.pingunaut.wicket.chartjs.core.DataSetChartPanel.java

@Override
public String generateChart() {
    String dataString = null;//  www  .  j  a  v  a2  s .com
    String optionString = null;
    try {
        dataString = getChart().getMapper().writeValueAsString(getChart().getData());
        optionString = getChart().getMapper().writeValueAsString(getChart().getOptions());
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    String js = "WicketCharts['" + getChartCanvas().getMarkupId() + "']."
            + getChart().getClass().getSimpleName() + "(" + dataString + ", " + optionString + ");";
    return js;
}

From source file:cn.com.esrichina.gcloud.commons.LicenseFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {

    String url = request.getRequestURI();
    Boolean result = matchExcludePatterns(url);
    if (result) {
        filterChain.doFilter(request, response);
        return;// ww  w.j  av a  2s. c om
    }

    if (licenceContext.getIsAuthorized()) {
        doFilter(request, response, filterChain);
    } else {
        response.setContentType("text/json;charset=UTF-8");

        // TODO ajax Json???HTTP?
        PrintWriter writer = response.getWriter();

        RestResponse res = new RestResponse(false, licenceContext.getReason());

        ObjectMapper mapper = new ObjectMapper();
        String json = "";
        try {
            json = mapper.writeValueAsString(res);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

        writer.print(json);
        writer.close();
    }
}

From source file:org.apache.kylin.job.common.HqlExecutable.java

public void setConfiguration(Map<String, String> configMap) {
    if (configMap != null) {
        String configStr = "";
        try {/*www. j  a  va  2 s . com*/
            configStr = JsonUtil.writeValueAsString(configMap);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        setParam(HIVE_CONFIG, configStr);
    }
}

From source file:cn.designthoughts.sample.axon.sfav.query.customer.controller.QueryCustomerController.java

@RequestMapping(value = "/rest/customers/{customerId}/addresses", method = RequestMethod.GET)
public String getCustomerAddresses(@PathVariable String customerId) {
    Iterable<AddressEntry> listAddresses = customerEntryRepository.findByIdentifier(customerId).getAddresses();
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    String listAddressesString = "";
    try {//from  www .  ja v a2s .  co  m
        listAddressesString = mapper.writeValueAsString(listAddresses);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return listAddressesString;
}

From source file:br.unicamp.cst.trafficUnjammer.experiments.communication.JsonHandler.java

/**
 *
 * @param typerefence/*from  ww  w  . j ava  2s.co m*/
 * @param objectNodeBase
 * @param jsonData
 * @return
 */
public <T> ArrayList<Object> fromJsonDataToListOfObject(TypeReference<T> typerefence, String jsonData) {

    ObjectMapper mapper = new ObjectMapper();
    ArrayList<Object> parsed = null;
    try {

        JsonNode node = mapper.readTree(jsonData);
        parsed = mapper.readValue(node.traverse(), typerefence);

    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return parsed;
}

From source file:cn.designthoughts.sample.axon.sfav.query.customer.controller.QueryCustomerController.java

@RequestMapping(value = "/rest/customers", method = RequestMethod.GET)
public String listCustomer() {
    Iterable<CustomerEntry> listCustomers = customerEntryRepository.findAll();
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    String listCustomerString = "";
    try {//from   w w  w  . j  a  va  2  s  .  c o  m
        listCustomerString = mapper.writeValueAsString(listCustomers);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    return listCustomerString;
}