|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.json.JSON
public class JSON
Contains utility methods for working with JSON or JSON-like data structures.
Special treatment is afforded to java.util.Map
and
org.apache.pivot.collections.Map
objects at any level
of the hierarchy. Otherwise a BeanAdapter
is used to
fetch the value from the object.
If, however, the object at a given level is a
Sequence
then the key
is assumed to be an integer index into the sequence.
Also, special consideration is given to an object that
implements the Dictionary
interface.
Constructor Summary | |
---|---|
JSON()
|
Method Summary | ||
---|---|---|
static
|
containsKey(Object root,
String path)
Tests the existence of a path in a given object. |
|
static
|
get(Object root,
Sequence<String> keys)
Returns the value at a given path. |
|
static
|
get(Object root,
String path)
Returns the value at a given path. |
|
static byte |
getByte(Object root,
String path)
|
|
static double |
getDouble(Object root,
String path)
|
|
static float |
getFloat(Object root,
String path)
|
|
static int |
getInt(Object root,
String path)
|
|
static long |
getLong(Object root,
String path)
|
|
static short |
getShort(Object root,
String path)
|
|
static Sequence<String> |
parse(String path)
Parses a JSON path into a sequence of string keys. |
|
static
|
put(Object root,
String path,
T value)
Sets the value at the given path. |
|
static
|
remove(Object root,
String path)
Removes the value at the given path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSON()
Method Detail |
---|
public static <T> T get(Object root, String path)
root
- The root object.path
- The path to the value as a JavaScript path.
get(Object, Sequence)
public static <T> T get(Object root, Sequence<String> keys)
root
- The root object.keys
- The path to the value as a sequence of keys.
public static byte getByte(Object root, String path)
public static short getShort(Object root, String path)
public static int getInt(Object root, String path)
public static long getLong(Object root, String path)
public static float getFloat(Object root, String path)
public static double getDouble(Object root, String path)
public static <T> T put(Object root, String path, T value)
root
- path
- value
-
public static <T> T remove(Object root, String path)
root
- path
-
public static <T> boolean containsKey(Object root, String path)
root
- path
-
public static Sequence<String> parse(String path)
path
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |