Search in sources :

Example 6 with JsonGenerationException

use of org.codehaus.jackson.JsonGenerationException in project appsly-android-rest by 47deg.

the class JacksonBodyConverter method toRequestBody.

@Override
public <T> HttpEntity toRequestBody(T object, String contentType) {
    Logger.d("JacksonBodyConverter.toRequestBody: object: " + object);
    try {
        String json = mapper.writeValueAsString(object);
        Logger.d("JacksonHttpFormValuesConverter.toRequestBody: json: " + json);
        StringEntity result = new StringEntity(json, "UTF-8");
        result.setContentType(contentType);
        Logger.d("JacksonBodyConverter.toRequestBody: result: " + result);
        return result;
    } catch (UnsupportedEncodingException e) {
        throw new SerializationException(e);
    } catch (JsonMappingException e) {
        throw new SerializationException(e);
    } catch (JsonGenerationException e) {
        throw new SerializationException(e);
    } catch (IOException e) {
        throw new SerializationException(e);
    }
}
Also used : StringEntity(org.apache.http.entity.StringEntity) SerializationException(ly.apps.android.rest.exceptions.SerializationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException)

Aggregations

JsonGenerationException (org.codehaus.jackson.JsonGenerationException)6 JsonGenerator (org.codehaus.jackson.JsonGenerator)4 IOException (java.io.IOException)3 JsonEncoding (org.codehaus.jackson.JsonEncoding)3 HttpMessageNotWritableException (org.springframework.http.converter.HttpMessageNotWritableException)3 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)2 SchemaId (com.linkedin.databus2.schemas.SchemaId)1 VersionedSchema (com.linkedin.databus2.schemas.VersionedSchema)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ByteBuffer (java.nio.ByteBuffer)1 SerializationException (ly.apps.android.rest.exceptions.SerializationException)1 Schema (org.apache.avro.Schema)1 GenericDatumReader (org.apache.avro.generic.GenericDatumReader)1 GenericDatumWriter (org.apache.avro.generic.GenericDatumWriter)1 JsonEncoder (org.apache.avro.io.JsonEncoder)1 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)1 StringEntity (org.apache.http.entity.StringEntity)1 JsonFactory (org.codehaus.jackson.JsonFactory)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1