| 1 |
package com.fasterxml.jackson.jr.retrofit2; |
| 2 |
|
| 3 |
import com.fasterxml.jackson.jr.ob.JSON; |
| 4 |
|
| 5 |
import okhttp3.ResponseBody; |
| 6 |
|
| 7 |
import java.io.IOException; |
| 8 |
|
| 9 |
import retrofit2.Converter; |
| 10 |
|
| 11 |
public class JacksonJrResponseConverter<T> implements Converter<ResponseBody, T> |
| 12 |
{ |
| 13 |
protected final JSON _jr; |
| 14 |
protected final Class<T> _type; |
| 15 |
|
| 16 |
public JacksonJrResponseConverter(JSON jr, Class<T> t) { |
| 17 |
_jr = jr; |
| 18 |
_type = t; |
| 19 |
} |
| 20 |
|
| 21 |
@Override |
| 22 |
public T convert(ResponseBody value) throws IOException { |
| 23 |
return _jr.beanFrom(_type, value.bytes()); |
| 24 |
} |
| 25 |
} |