public class JSONDocument extends Object implements Iterable<JSONDocument>
Modifier and Type | Class and Description |
---|---|
static class |
JSONDocument.Type
The type of a JSON node.
|
Modifier and Type | Field and Description |
---|---|
static JSONDocument |
EMPTY_ARRAY
An empty array.
|
static JSONDocument |
EMPTY_OBJECT
An empty object.
|
static String |
JSON_XPATH_URI
URI for use in
XPathFactory to specify
a subset of XPath over JSON. |
Constructor and Description |
---|
JSONDocument(JSONDocument.Type type)
Constructs an empty node of the specified type.
|
Modifier and Type | Method and Description |
---|---|
List<Object> |
array()
Returns the array representation of the node.
|
static JSONDocument |
createArray() |
static JSONDocument |
createArray(int length) |
static JSONDocument |
createObject() |
boolean |
equals(Object obj) |
JSONDocument |
get(int index)
Get child of this array node.
|
JSONDocument |
get(String key)
Get child of this object node.
|
Boolean |
getBoolean(int index)
Get the array node's value at specified index as a Boolean.
|
Boolean |
getBoolean(String key)
Get the object node's named value as a Boolean.
|
List<Object> |
getList(int index)
Get child array of this array node as a List.
|
List<Object> |
getList(String key)
Get child array of this object node as a List.
|
Map<String,Object> |
getMap(int index)
Get child object of this array node as a Map.
|
Map<String,Object> |
getMap(String key)
Get child object of this object node as a Map.
|
Number |
getNumber(int index)
Get the array node's value at specified index as a Number.
|
Number |
getNumber(String key)
Get the object node's named value as a Number.
|
String |
getString(int index)
Get the array node's value at specified index as a String.
|
String |
getString(String key)
Get the object node's named value as a String.
|
int |
hashCode() |
boolean |
isArray()
Test if the node is an ARRAY.
|
boolean |
isNull(int index)
Get if the array node's value at specified index is null.
|
boolean |
isNull(String key)
Get if the object node's named value is null.
|
boolean |
isObject()
Test if the node is an OBJECT.
|
com.oracle.javafx.jmx.json.JSONDocument.IteratorWrapper |
iterator() |
Map<String,Object> |
object()
Returns the map representation of the node.
|
JSONDocument |
set(int index,
JSONDocument value)
Set child object of this node.
|
JSONDocument |
set(String key,
JSONDocument child)
Set child object of this node.
|
Boolean |
setBoolean(int index,
Boolean value)
Set value of this node as Boolean.
|
Boolean |
setBoolean(String key,
Boolean value)
Set value of this node as Boolean.
|
Object |
setNull(int index)
Set value of this node to null.
|
Object |
setNull(String key)
Set value of this node to null.
|
Number |
setNumber(int index,
Number value)
Set value of this node as Number.
|
Number |
setNumber(String key,
Number value)
Set value of this node as Number.
|
String |
setString(int index,
String value)
Set value of this node as String.
|
String |
setString(String key,
String value)
Set value of this node as String.
|
String |
toJSON()
Returns a string representation of the node and its children,
without newlines or whitespace.
|
void |
toJSON(Writer writer)
Writes a string representation of the node and its children,
without newlines or whitespace, to the supplied Writer.
|
String |
toString() |
JSONDocument.Type |
type()
Returns the type of the node
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static final String JSON_XPATH_URI
XPathFactory
to specify
a subset of XPath
over JSON.public static final JSONDocument EMPTY_ARRAY
public static final JSONDocument EMPTY_OBJECT
public JSONDocument(JSONDocument.Type type)
type
- the type of the node, an ARRAY or an OBJECT.public static JSONDocument createObject()
public static JSONDocument createArray()
public static JSONDocument createArray(int length)
public JSONDocument.Type type()
public List<Object> array()
public Map<String,Object> object()
public boolean isArray()
public boolean isObject()
public void toJSON(Writer writer) throws IOException
IOException
- if there are errors writing to the Writerfor a variant that returns a String
,
for a human-readable representation
public String toJSON()
for a human-readable representation
public JSONDocument get(String key)
key
- the key for the current object node whose value
is to be retrievedpublic JSONDocument get(int index)
index
- the index for the current array node at which the node
is to be retrievedpublic Map<String,Object> getMap(String key)
key
- the key for the current object node whose value
is to be retrievedpublic Map<String,Object> getMap(int index)
index
- the index for the current array node at which the node
is to be retrievedpublic List<Object> getList(String key)
key
- the key for the current object node whose value
is to be retrievedpublic List<Object> getList(int index)
index
- the index for the current array node at which the node
is to be retrievedpublic String getString(String key)
key
- the name of the valuepublic String getString(int index)
index
- the array index whose value is to be returnedpublic Boolean getBoolean(String key)
key
- the name of the valuepublic Boolean getBoolean(int index)
index
- the array index whose value is to be returnedpublic Number getNumber(String key)
key
- the name of the valuepublic Number getNumber(int index)
index
- the array index whose value is to be returnedpublic boolean isNull(String key)
key
- the name of the valuepublic boolean isNull(int index)
index
- the array index whose value is to be checkedpublic JSONDocument set(String key, JSONDocument child)
key
- the name of the childvalue
- the node containing the new valuespublic JSONDocument set(int index, JSONDocument value)
index
- the index at which the child is to be setvalue
- the node containing the new valuespublic String setString(String key, String value)
key
- the name of the valuevalue
- the new valuepublic String setString(int index, String value)
index
- the index at which the value is to be setvalue
- the new valuepublic Boolean setBoolean(String key, Boolean value)
key
- the name of the valuevalue
- the new valuepublic Boolean setBoolean(int index, Boolean value)
index
- the index at which the value is to be setvalue
- the new valuepublic Number setNumber(String key, Number value)
key
- the name of the valuevalue
- the new valuepublic Number setNumber(int index, Number value)
index
- the index at which the value is to be setvalue
- the new valuepublic Object setNull(String key)
key
- the name of the valuepublic Object setNull(int index)
index
- the index at which the value is to be setvalue
- the new valuepublic com.oracle.javafx.jmx.json.JSONDocument.IteratorWrapper iterator()
iterator
in interface Iterable<JSONDocument>
Copyright © 2020. All rights reserved.