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

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

Introduction

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

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.dcache.util.histograms.HistogramModelTest.java

private void whenHistogramIsSerialized() {
    try {/* www  .  ja  va 2s . c  o m*/
        serialized1 = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(model);
    } catch (JsonProcessingException e) {
        assertNull(e.toString(), e);
    }
}

From source file:org.dcache.util.histograms.HistogramModelTest.java

private void whenHistogramIsSerializedAgain() {
    try {//from   w  w  w  .  j  ava2s.  com
        serialized2 = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(model);
    } catch (JsonProcessingException e) {
        assertNull(e.toString(), e);
    }
}

From source file:org.wikidata.wdtk.wikibaseapi.WbEditEntityAction.java

/**
 * Parse a JSON response to extract an entity document.
 * <p>//w  w w.j  a  v a 2  s .c om
 * TODO This method currently contains code to work around Wikibase issue
 * https://phabricator.wikimedia.org/T73349. This should be removed once the
 * issue is fixed.
 *
 * @param entityNode
 *            the JSON node that should contain the entity document data
 * @return the entitiy document, or null if there were unrecoverable errors
 * @throws IOException
 * @throws JsonProcessingException
 */
private EntityDocument parseJsonResponse(JsonNode entityNode) throws JsonProcessingException, IOException {
    try {
        JacksonTermedStatementDocument ed = mapper.treeToValue(entityNode,
                JacksonTermedStatementDocument.class);
        ed.setSiteIri(this.siteIri);

        return ed;
    } catch (JsonProcessingException e) {
        logger.warn("Error when reading JSON for entity " + entityNode.path("id").asText("UNKNOWN") + ": "
                + e.toString() + "\nTrying to manually fix issue https://phabricator.wikimedia.org/T73349.");
        String jsonString = entityNode.toString();
        jsonString = jsonString.replace("\"sitelinks\":[]", "\"sitelinks\":{}")
                .replace("\"labels\":[]", "\"labels\":{}").replace("\"aliases\":[]", "\"aliases\":{}")
                .replace("\"claims\":[]", "\"claims\":{}")
                .replace("\"descriptions\":[]", "\"descriptions\":{}");

        ObjectReader documentReader = this.mapper.reader(JacksonTermedStatementDocument.class);

        JacksonTermedStatementDocument ed;
        ed = documentReader.readValue(jsonString);
        ed.setSiteIri(this.siteIri);
        return ed;
    }
}