com.strongloop.android.remoting

## Class JsonUtil

- java.lang.Object
- - com.strongloop.android.remoting.JsonUtil

    public class JsonUtil
    extends java.lang.Object

Utility methods for converting JSON objects to Java collection objects (and vice versa).

### Constructor Summary

Constructors
Constructor and Description
`JsonUtil()`

### Method Summary

Methods
`static java.util.List<java.lang.Object>` `fromJson(JSONArray array)` Converts a `org.json.JSONArray` to a `List`.
`static java.util.Map<java.lang.String,java.lang.Object>` `fromJson(JSONObject object)` Converts a `org.json.JSONObject` to a `Map`.
`static java.lang.Object` `toJson(java.lang.Object object)` Converts a Java object to a JSON object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### JsonUtil

    public JsonUtil()

### Method Detail

#### toJson

    public static java.lang.Object toJson(java.lang.Object object)
                                   throws JSONException

Converts a Java object to a JSON object. A `Map` is converted to a `org.json.JSONObject`, a `List` or array is converted to a `org.json.JSONArray`, and `null` is converted to `org.json.JSONObject#NULL`. Other objects, like `Number`, `String`, and `Boolean` are returned without conversion.

Parameters:
  `object` - The object to convert.
Returns:
  a JSON object.
Throws:
  `JSONException` - If the object cannot be converted.

#### fromJson

    public static java.util.Map<java.lang.String,java.lang.Object> fromJson(JSONObject object)

Converts a `org.json.JSONObject` to a `Map`.

Parameters:
  `object` - The JSON object to convert.
Returns:
  a map, or `null` if the object is `null`.
Throws:
  `JSONException` - If the object cannot be converted.

#### fromJson

    public static java.util.List<java.lang.Object> fromJson(JSONArray array)

Converts a `org.json.JSONArray` to a `List`.

Parameters:
  `array` - The JSON array to convert.
Returns:
  a list, or `null` if the array is `null`.
Throws:
  `JSONException` - If the array cannot be converted.