All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.jackson.jr.retrofit2.JacksonJrRequestBodyConverter Maven / Gradle / Ivy

There is a newer version: 2.18.2
Show newest version
package com.fasterxml.jackson.jr.retrofit2;

import java.io.IOException;

import okhttp3.MediaType;
import okhttp3.RequestBody;

import retrofit2.Converter;

import com.fasterxml.jackson.jr.ob.JSON;

public class JacksonJrRequestBodyConverter implements Converter
{
    private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
    protected static final String PROTOCOL_CHARSET = "utf-8";

    protected final JSON _jr;

    public JacksonJrRequestBodyConverter(JSON jr) {
        _jr = jr;
    }

    @Override
    public RequestBody convert(T value) throws IOException {

        byte[] bytes = _jr.asBytes(value);
        return RequestBody.create(MEDIA_TYPE, bytes);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy