public class JsonUtil
extends java.lang.Object
Dates are rendered as strings, but they do not parse back as dates.
There are other utilities for this but they all seem to be way over-engineered for my taste. I just want to get a generic Map/List/String model through JSON. If you want to reflectively serialize arbitrary Java classes then use something else.
NOTE: This is part of the standalone integration jar and must have NO dependencies to IIQ classes other than the ones in this package, and it must NOT use JDK 1.5 features.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DATE_FORMAT
Date format we render.
|
static boolean |
SortMapKeys
A global flag controlling whether we sort map keys before
rendering.
|
| Constructor and Description |
|---|
JsonUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Map<java.lang.String,java.lang.Object> |
jsonToMap(JSONObject json)
This method returns HashMap from JSON object
|
static java.lang.Object |
parse(java.lang.String json)
Public interface for parsing JSON that conforms to our restrictions.
|
static java.lang.String |
render(java.lang.Object o)
Public interface to rendering something as a JSON string.
|
static java.util.List<java.lang.Object> |
toList(JSONArray array)
Method to return list of Object from JSONArray
|
public static boolean SortMapKeys
It probably wouldn't hurt to leave this on all the time, we shouldn't have many large maps?
public static final java.lang.String DATE_FORMAT
public static java.lang.String render(java.lang.Object o)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.Object parse(java.lang.String json)
public static java.util.Map<java.lang.String,java.lang.Object> jsonToMap(JSONObject json)
throws JSONException
json - JSONExceptionpublic static java.util.List<java.lang.Object> toList(JSONArray array)
throws JSONException
array - JSONException