public class JSONFactory
extends java.lang.Object
class Car { private int id; private String description; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } }You can retrieve a new Car object using:
Car cc = JSONFactory.parse("{\"carro\":{\"id\":-1,\"descricao\":\"GOL\"}}", Carro.class);You may also retrieve a list or an array. See the JSONSample in the TotalCrossAPI.
Constructor and Description |
---|
JSONFactory() |
Modifier and Type | Method and Description |
---|---|
static <T> java.util.List<T> |
asList(java.lang.String json,
java.lang.Class<T> classOfT) |
static <T> T |
parse(JSONArray jsonArray,
java.lang.Class<T> classOfT) |
static <T> T |
parse(JSONObject jsonObject,
java.lang.Class<T> classOfT) |
static <T> T |
parse(java.lang.String json,
java.lang.Class<T> classOfT) |
public static <T> java.util.List<T> asList(java.lang.String json, java.lang.Class<T> classOfT) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, JSONException, java.lang.ArrayIndexOutOfBoundsException, java.lang.NoSuchMethodException, java.lang.SecurityException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
JSONException
java.lang.ArrayIndexOutOfBoundsException
java.lang.NoSuchMethodException
java.lang.SecurityException
public static <T> T parse(java.lang.String json, java.lang.Class<T> classOfT) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, JSONException, java.lang.NoSuchMethodException, java.lang.SecurityException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
JSONException
java.lang.NoSuchMethodException
java.lang.SecurityException
public static <T> T parse(JSONArray jsonArray, java.lang.Class<T> classOfT) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, JSONException, java.lang.ArrayIndexOutOfBoundsException, java.lang.NoSuchMethodException, java.lang.SecurityException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
JSONException
java.lang.ArrayIndexOutOfBoundsException
java.lang.NoSuchMethodException
java.lang.SecurityException
public static <T> T parse(JSONObject jsonObject, java.lang.Class<T> classOfT) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, JSONException, java.lang.NoSuchMethodException, java.lang.SecurityException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
JSONException
java.lang.NoSuchMethodException
java.lang.SecurityException