Class RMJSONNode
- java.lang.Object
-
- com.inductiveautomation.rm.archiver.RMJSONNode
-
public class RMJSONNode extends java.lang.ObjectRepresents a node in a JSON tree.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRMJSONNode.Type
-
Constructor Summary
Constructors Constructor Description RMJSONNode()Creates a new node.RMJSONNode(java.lang.Object aSource)Creates a new node.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RMJSONNodeget(int anIndex)Returns the individual node at given index.RMJSONNodeget(java.lang.String aKey)Returns value for key if node type Map.java.lang.BooleangetBoolean()Returns the value as Map if type is Map.protected RMJSONNodegetJSON(java.lang.Object anObj)Returns a JSON node of given value.java.util.List<java.lang.String>getKeys()Returns keys list.java.util.ListgetList()Returns the value as List if type is List.java.util.Map<java.lang.String,java.lang.Object>getMap()Returns the value as Map if type is Map.java.lang.ObjectgetNonJSON()Converts a JSON object to Map.java.lang.NumbergetNumber()Returns the value as Number if type is Number.java.lang.StringgetString()Returns the value as String if type is String.RMJSONNode.TypegetType()Returns the the node type.java.lang.ObjectgetValue()Returns the value.static voidmain(java.lang.String[] args)Simple main implementation to read standard in and re-print JSON.RMJSONNodeput(java.lang.String aKey, java.lang.Object aValue)Sets value for key.static RMJSONNodereadSource(java.lang.Object aSource)Creates a JSON node tree from a JSON string or JSON String byte source.protected voidsetType(RMJSONNode.Type aType)Sets the node type.protected RMJSONNodesetValue(java.lang.Object anObj)Sets the value.intsize()Returns the number of JSON nodes if node type List.java.lang.StringtoString()Returns a string representation of node (as JSON, of course).java.lang.StringtoStringCompacted()Returns a string representation of node (as JSON, of course).
-
-
-
Method Detail
-
readSource
public static RMJSONNode readSource(java.lang.Object aSource) throws RMJSONReader.RMJSONException
Creates a JSON node tree from a JSON string or JSON String byte source.- Throws:
RMJSONReader.RMJSONException
-
getType
public RMJSONNode.Type getType()
Returns the the node type.
-
setType
protected void setType(RMJSONNode.Type aType)
Sets the node type.
-
getValue
public java.lang.Object getValue()
Returns the value.
-
setValue
protected RMJSONNode setValue(java.lang.Object anObj)
Sets the value.
-
get
public RMJSONNode get(java.lang.String aKey)
Returns value for key if node type Map.
-
put
public RMJSONNode put(java.lang.String aKey, java.lang.Object aValue)
Sets value for key.
-
getKeys
public java.util.List<java.lang.String> getKeys()
Returns keys list.
-
size
public int size()
Returns the number of JSON nodes if node type List.
-
get
public RMJSONNode get(int anIndex)
Returns the individual node at given index.
-
getJSON
protected RMJSONNode getJSON(java.lang.Object anObj)
Returns a JSON node of given value.
-
getMap
public java.util.Map<java.lang.String,java.lang.Object> getMap()
Returns the value as Map if type is Map.
-
getList
public java.util.List getList()
Returns the value as List if type is List.
-
getString
public java.lang.String getString()
Returns the value as String if type is String.
-
getNumber
public java.lang.Number getNumber()
Returns the value as Number if type is Number.
-
getBoolean
public java.lang.Boolean getBoolean()
Returns the value as Map if type is Map.
-
getNonJSON
public java.lang.Object getNonJSON()
Converts a JSON object to Map.
-
toString
public java.lang.String toString()
Returns a string representation of node (as JSON, of course).- Overrides:
toStringin classjava.lang.Object
-
toStringCompacted
public java.lang.String toStringCompacted()
Returns a string representation of node (as JSON, of course).
-
main
public static void main(java.lang.String[] args)
Simple main implementation to read standard in and re-print JSON.
-
-