|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.paas.orchestrator.provisioning.util.JSONUtil
public class JSONUtil
This class provides basic JSON encoding / decoding. It has 2 primary methods that are of interest. The first allows you to encode a Java Object into JSON. The other allows you to create a Java data structure from a JSON String. See:
| Constructor Summary | |
|---|---|
JSONUtil()
|
|
| Method Summary | |
|---|---|
static String |
javaToJSON(Object obj,
int depth)
This method attempts to convert the given Object into a JSON String to given depth. |
static Object |
jsonToJava(String json)
This method returns a Java representation of the given JSON String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JSONUtil()
| Method Detail |
|---|
public static Object jsonToJava(String json)
This method returns a Java representation of the given JSON String. The Java data structure created will be created using Map's, String's, Long's, Float's, Boolean's, and List's as specified by the JSON String.
public static String javaToJSON(Object obj,
int depth)
This method attempts to convert the given Object into a JSON String to given depth. If -1 (or lower) is supplied for depth, it will walk upto a default depth of 10 levels of the given Object. If 0 is supplied, it will simply return "". 1 will encode the current Object, but no children. 2 will encode the given Object and its direct children (if any), and so on.
Strings, Longs, Float, and primitives are considered to not have child Objects. Objects which have a public no-argument getXYZ() method are considered to be child Objects. Maps and Collections will be walked.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||