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:Sandbox.java

@Test
public void playAround() {
    String json = null;/*from  w  w  w  . j  av  a  2s.  c  om*/
    ObjectifyJacksonModule ojm = new ObjectifyJacksonModule();
    ObjectMapper mapper = new ObjectMapper();

    mapper.registerModule(ojm);

    Key key = Key.create(Artist.class, "the-beatles");

    logger.info("Web Safe String = " + key.getString());
    logger.info("toString() = " + key.toString());

    try {
        json = mapper.writeValueAsString(key);
    } catch (JsonProcessingException jpe) {
        jpe.printStackTrace();
    }

    logger.info("Serializing '" + json + "'.");
}

From source file:com.datasift.client.core.Balance.java

@Override
public String toString() {
    try {//from   www. j  a  v  a 2  s . co m
        return DataSiftClient.MAPPER.writeValueAsString(this);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return "Unable to generate string representation of this response/result";
    }
}

From source file:com.springboot.demo.domain.City.java

@Override
public String toJsonString() {
    final ObjectMapper jacksonObjectMapper = new ObjectMapper();
    try {/*from w w  w.ja v a2  s . co m*/
        return jacksonObjectMapper.writeValueAsString(this);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:MiniServer.EntryPoint.java

/**
 * Gets the person card info for a given ID
 * Example usage: GET request to the URI: /api/cc/423423
 * @param user_id//from   ww w . j  av a 2s .  c o  m
 */
@GET
@Path("/cc/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response getPersonData(@PathParam("id") String id) {

    db.connect(databasePath);
    CardData card = db.getInfoByIID(id);
    db.connection_close();

    String res;
    if (card != null) {
        try {
            res = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(card);
            return Response.status(200).entity(res).build();
        } catch (JsonProcessingException ex) {
            ex.printStackTrace();
        }
    }
    res = "Person does not exist in the database";
    return Response.status(404).entity(res).build();

}

From source file:com.samples.platform.serviceprovider.techsupport.flow.test.MockFlowLogMessagePersistence.java

@Override
public void submitFlowLogMessage(final FlowLogMessageType log) {
    ObjectMapper mapper = new ObjectMapper();

    try {// w  ww. ja v  a 2 s . co m
        this.logger.debug(mapper.writeValueAsString(log));
    } catch (JsonProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        this.logger.error(e.getMessage(), e);
    }
}

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

@Override
public void run() {
    ObjectMapper objectMapper = new ObjectMapper();
    try {/*from ww w.  j a v  a2s  . c o  m*/
        System.out.println("------- without custom serializer -------");
        Object pojo = new Object() {
            public int intv = 10;
            public EncodePojoEnum enum1 = EncodePojoEnum.ONE;
            public EncodePojoEnum2 enum2 = EncodePojoEnum2.DEF;
        };
        System.out.println(objectMapper.writeValueAsString(pojo));
        System.out.println("------- with custom serializer -------");
        Object pojo2 = new Object() {
            public int intv = 10;

            @JsonSerialize(using = EncodePojoEnumJacksonSerializer.class)
            public EncodePojoEnum enum1 = EncodePojoEnum.ONE;

            @JsonSerialize(using = EncodePojoEnum2JacksonSerializer.class)
            public EncodePojoEnum2 enum2 = EncodePojoEnum2.DEF;
        };
        System.out.println(objectMapper.writeValueAsString(pojo2));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

@Override
public Activity deserialize(String serialized) throws ActivitySerializerException {

    ObjectMapper mapper = StreamsTwitterMapper.getInstance();
    Tweet tweet = null;/*from   w  w  w .  ja  v  a 2 s  . c o m*/
    try {
        tweet = mapper.readValue(serialized, Tweet.class);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Activity activity = new Activity();

    updateActivity(tweet, activity);

    return activity;
}

From source file:com.onedrive.api.resource.Resource.java

@Override
public String toString() {
    if (oneDrive != null) {
        try {//from w  w  w  . j  av a  2 s. c o  m
            return getOneDrive().getObjectMapper().writeValueAsString(this);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
    }
    return super.toString();
}

From source file:org.apache.streams.instagram.serializer.InstagramJsonActivitySerializer.java

@Override
public Activity deserialize(String serialized) throws ActivitySerializerException {

    ObjectMapper mapper = StreamsJacksonMapper.getInstance();
    MediaFeedData mediaFeedData = null;//from w ww .  j a va  2  s  .  co m

    try {
        mediaFeedData = mapper.readValue(serialized, MediaFeedData.class);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Activity activity = new Activity();

    updateActivity(mediaFeedData, activity);

    return activity;
}

From source file:io.cortical.retina.core.Classify.java

/**
 * Endpoint for creating a {@link CategoryFilter} from text inputs.
 * /*from ww w . ja  v a 2 s  .com*/
 * @param filterName            the name of the category filter
 * @param positiveExamples      list of strings illustrating positive examples.
 * @param negativeExamples      list of strings illustrating negative examples.
 * @return {@link CategoryFilter}
 * @throws ApiException if problem occurs accessing the api
 */
public CategoryFilter createCategoryFilter(String filterName, List<String> positiveExamples,
        List<String> negativeExamples) throws ApiException {
    if (isEmpty(filterName) || positiveExamples == null || positiveExamples.isEmpty()) {
        throw new IllegalArgumentException(NULL_TEXT_MSG);
    }

    Sample sample = makeSample(positiveExamples, negativeExamples);

    String json = null;
    try {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(Include.NON_NULL);
        json = mapper.writeValueAsString(sample);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    return this.api.createCategoryFilter(filterName, json, retinaName);
}