|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.javajson.JsonObject
public class JsonObject
Simpler implementation of Json that throws less exceptions. For all the getXXX method, if the item is not found, it returns null, false, or 0. If they key is null or otherwise invalid, it throws an exception.
Constructor Summary | |
---|---|
JsonObject()
|
Method Summary | |
---|---|
JsonObject |
accumulate(String key,
boolean val)
Accumlates multiple values into an array. |
JsonObject |
accumulate(String key,
double val)
Accumlates multiple values into an array. |
JsonObject |
accumulate(String key,
float val)
Accumlates multiple values into an array. |
JsonObject |
accumulate(String key,
int val)
Accumlates multiple values into an array. |
JsonObject |
accumulate(String key,
JsonArray val)
Accumlates multiple values into an array. |
JsonObject |
accumulate(String key,
JsonObject val)
Accumlates multiple values into an array. |
JsonObject |
accumulate(String key,
String val)
Accumlates multiple values into an array. |
boolean |
getBoolean(String key)
|
double |
getDouble(String key)
|
float |
getFloat(String key)
|
int |
getInt(String key)
|
JsonArray |
getJsonArray(String key)
|
JsonObject |
getJsonObject(String key)
|
long |
getLong(String key)
|
String |
getString(String key)
|
boolean |
hasKey(String key)
|
boolean |
isBoolean(String key)
Checks if the item at a key is a boolean. |
boolean |
isDouble(String key)
Checks if the item at a key is a double. |
boolean |
isFloat(String key)
Checks if the item at a key is a float. |
boolean |
isInt(String key)
Checks if the item at a key is a int. |
boolean |
isJsonArray(String key)
Checks if the item at a key is an array. |
boolean |
isJsonObject(String key)
Checks if the item at a key is an object. |
boolean |
isLong(String key)
Checks if the item at a key is a long. |
boolean |
isNull(String key)
Checks if the field contains a null value (different than hasKey because it can have the key but be null) |
boolean |
isSimilar(JsonObject obj)
checks that this object contains all fields as passed object. |
boolean |
isString(String key)
Checks if the item at a key is an string. |
Iterator<String> |
iterator()
|
static JsonObject |
parse(InputStream is)
Parses a string to a json object. |
static JsonObject |
parse(Reader reader)
Parses a string to a json object. |
static JsonObject |
parse(String input)
Parses a string to a json object. |
JsonObject |
put(String key,
boolean value)
|
JsonObject |
put(String key,
double value)
|
JsonObject |
put(String key,
float value)
|
JsonObject |
put(String key,
int value)
|
JsonObject |
put(String key,
JsonArray value)
|
JsonObject |
put(String key,
JsonObject value)
|
JsonObject |
put(String key,
long value)
|
void |
put(String key,
Object value)
|
JsonObject |
put(String key,
String value)
|
int |
size()
|
String |
toString()
|
String |
toString(int spacing)
Returns a nicely formatted string |
protected String |
toString(int spacing,
int margin)
Called by toString(int) to keep track of the spacing |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JsonObject()
Method Detail |
---|
public static JsonObject parse(String input) throws JsonException
JsonException
public static JsonObject parse(Reader reader) throws JsonException
JsonException
public static JsonObject parse(InputStream is) throws JsonException
JsonException
public JsonObject accumulate(String key, boolean val)
key
- val
- public JsonObject accumulate(String key, double val)
key
- val
- public JsonObject accumulate(String key, float val)
key
- val
- public JsonObject accumulate(String key, int val)
key
- val
- public JsonObject accumulate(String key, JsonArray val)
key
- val
- public JsonObject accumulate(String key, JsonObject val)
key
- val
- public JsonObject accumulate(String key, String val)
key
- val
- public boolean getBoolean(String key)
public double getDouble(String key)
public float getFloat(String key)
public int getInt(String key)
public JsonArray getJsonArray(String key)
public JsonObject getJsonObject(String key)
public long getLong(String key)
public String getString(String key)
public boolean hasKey(String key)
public boolean isBoolean(String key)
JsonValue.isBoolean()
for more information
key
-
public boolean isDouble(String key)
JsonValue.isDouble()
for more information
key
- public boolean isFloat(String key)
JsonValue.isFloat()
for more information
key
- public boolean isInt(String key)
JsonValue.isInt()
for
more information
key
- public boolean isLong(String key)
JsonValue.isLong()
for
more information
key
- public boolean isJsonArray(String key)
JsonValue.isJsonArray()
for more information
key
-
public boolean isJsonObject(String key)
JsonValue.isJsonObject()
for more information
key
-
public boolean isNull(String key)
public boolean isSimilar(JsonObject obj)
obj
-
public boolean isString(String key)
JsonValue.isString()
for more information
key
-
public Iterator<String> iterator()
iterator
in interface Iterable<String>
public void put(String key, Object value)
public JsonObject put(String key, boolean value)
public JsonObject put(String key, double value)
public JsonObject put(String key, float value)
public JsonObject put(String key, int value)
public JsonObject put(String key, JsonArray value)
public JsonObject put(String key, JsonObject value)
public JsonObject put(String key, long value)
public JsonObject put(String key, String value)
public int size()
public String toString()
toString
in class Object
public String toString(int spacing)
spacing
-
protected String toString(int spacing, int margin)
spacing
- margin
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |