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

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.parworks.androidlibrary.response.ARResponseHandlerImpl.java

@Override
public <T> T handleResponse(JsonParser jp, Class<T> typeOfResponse) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    T responseObject = null;//  ww w  . j a  v  a 2  s  .  c  o m
    try {
        responseObject = mapper.readValue(jp, typeOfResponse);
    } catch (JsonParseException e) {
        throw new ARException("Couldn't create the object " + typeOfResponse
                + " because the json was malformed : " + jp.toString(), e);
    } catch (JsonMappingException e) {
        throw new ARException("Mapping the json response to the response object " + typeOfResponse
                + " failed.  Json was : " + jp.toString(), e);
    } catch (IllegalStateException e) {
        throw new ARException("Couldn't convert the json to object " + typeOfResponse
                + " because of illegal state. Json was : " + jp.toString(), e);
    } catch (IOException e) {
        throw new ARException("Couldn't convert the json to object " + typeOfResponse
                + " because of an ioexception. Json was : " + jp.toString(), e);
    }
    return responseObject;
}