程序包 com.sh.json
接口 JSON
- 所有超级接口:
Serializable
- 所有已知实现类:
JSONArray,JSONNull,JSONObject
Marker interface, identifies a valid JSON value.
A JSON value may be a
A JSON value may be a
JSONObject, a JSONArray or a
JSONNull.-
方法概要
修饰符和类型方法说明booleanisArray()Returns true if this object is a JSONArray, false otherwise.booleanisEmpty()Returns true if this object has no elements or keys.static JSONArrayparseArray(String str) static JSONObjectparseObject(String str) intsize()Returns the number of properties in an object or the size of the array.static byte[]toJSONBytes(JSONArray object) static byte[]toJSONBytes(JSONObject object) toString(int indentFactor) Make a prettyprinted JSON text.toString(int indentFactor, int indent) Make a prettyprinted JSON text.Write the contents as JSON text to a writer.
-
方法详细资料
-
isArray
boolean isArray()Returns true if this object is a JSONArray, false otherwise. -
isEmpty
boolean isEmpty()Returns true if this object has no elements or keys.- 抛出:
JSONException- if called on a 'null' object
-
size
int size()Returns the number of properties in an object or the size of the array.- 返回:
- the size of an json object or array
- 抛出:
JSONException- if called on a 'null' object
-
toString
Make a prettyprinted JSON text.Warning: This method assumes that the data structure is acyclical.
- 参数:
indentFactor- The number of spaces to add to each level of indentation.- 返回:
- a printable, displayable, portable, transmittable representation
of the object, beginning with
{(left brace) and ending with}(right brace). - 抛出:
JSONException- If the object contains an invalid number.
-
toString
Make a prettyprinted JSON text.Warning: This method assumes that the data structure is acyclical.
- 参数:
indentFactor- The number of spaces to add to each level of indentation.indent- The indentation of the top level.- 返回:
- a printable, displayable, transmittable representation of the
object, beginning with
{(left brace) and ending with}(right brace). - 抛出:
JSONException- If the object contains an invalid number.
-
write
Write the contents as JSON text to a writer. For compactness, no whitespace is added.Warning: This method assumes that the data structure is acyclical.
- 返回:
- The writer.
- 抛出:
JSONException
-
parseObject
-
parseArray
-
toJSONBytes
-
toJSONBytes
-