public class JsonBean extends Object
Modifier and Type | Field and Description |
---|---|
protected org.json.JSONObject |
json |
Constructor and Description |
---|
JsonBean() |
JsonBean(org.json.JSONObject json) |
Modifier and Type | Method and Description |
---|---|
Object |
get(String key) |
org.json.JSONArray |
getArray(String name) |
Boolean |
getBoolean(String name) |
boolean |
getBooleanValue(String property)
Helper method to extract data field from underlying JSONObject
|
boolean |
getBooleanValue(String property,
boolean defaultValue)
Helper method to extract data field from underlying JSONObject
|
double |
getDoubleValue(String property)
Helper method to extract data field from underlying JSONObject
|
double |
getDoubleValue(String property,
double defaultValue) |
Integer |
getInteger(String name) |
int |
getIntegerValue(String property)
Helper method to extract data field from underlying JSONObject
|
org.json.JSONObject |
getJson()
Gets the underlying JSONObject
|
<T> T |
getJsonBean(org.json.JSONObject obj,
Class<T> clazz) |
<T> T |
getJsonBean(String name,
Class<T> clazz) |
<T extends JsonBean> |
getJsonBeanList(String name,
Class<T> clazz) |
org.json.JSONObject |
getJsonCopy()
Gets a copy of underlying JSONObject
|
org.json.JSONObject |
getJsonValue(String property)
Helper method to extract data field from underlying JSONObject
|
<T> List<T> |
getList(String name) |
Rectangle |
getRectangle(String name) |
String |
getString(String property)
Helper method to extract data field from underlying JSONObject
|
JsonBean |
put(String key,
Object value)
Set value for a property
|
<T> void |
setArray(String name,
Collection<T> value) |
void |
setBoolean(String name,
Boolean value) |
void |
setInteger(String name,
Integer value) |
<T> void |
setJsonArray(String name,
List<T> values) |
<T extends JsonBean> |
setJsonBean(String name,
T jsonBean) |
void |
setLong(String name,
Long value) |
void |
setRectangle(String name,
Rectangle rect) |
void |
setString(String name,
String value) |
String |
toString() |
public org.json.JSONObject getJson()
public final org.json.JSONObject getJsonCopy()
public String getString(String property)
property
- name of the fieldpublic int getIntegerValue(String property)
property
- name of the fieldpublic double getDoubleValue(String property)
property
- name of the fieldpublic double getDoubleValue(String property, double defaultValue)
public boolean getBooleanValue(String property)
property
- name of the fieldpublic boolean getBooleanValue(String property, boolean defaultValue)
property
- name of the fielddefaultValue
- default value if property is missingpublic org.json.JSONObject getJsonValue(String property)
property
- name of the fieldpublic JsonBean put(String key, Object value) throws org.json.JSONException
key
- name of the propertyvalue
- valueorg.json.JSONException
- from JSONObject.putpublic <T> void setArray(String name, Collection<T> value)
public org.json.JSONArray getArray(String name)
public <T> T getJsonBean(org.json.JSONObject obj, Class<T> clazz)
Copyright © 2022. All rights reserved.