public class ObjectMapper
extends java.lang.Object
It would be awesome if there were a lightweight library that supported converting between
arbitrary Object and JSONObject representations.
Admittedly the other approach would be to use an Annotation Processor to create static conversion
functions that discover something like a JsonProperty and create a function at compile
time however since this is just being used for a simple debug utility and Kit-Kat caches the
results of reflection this class is sufficient for stethos needs.
| Constructor and Description |
|---|
ObjectMapper() |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
convertValue(java.lang.Object fromValue,
java.lang.Class<T> toValueType)
Support mapping between arbitrary classes and
JSONObject. |
public <T> T convertValue(java.lang.Object fromValue,
java.lang.Class<T> toValueType)
throws java.lang.IllegalArgumentException
JSONObject.
Throwable to be propagated out of this class if there is an
InvocationTargetException.
T - fromValue - toValueType - java.lang.IllegalArgumentException - when there is an error converting. One of either
fromValue.getClass() or toValueType must be JSONObject.