Class RMJSONNode
- java.lang.Object
-
- com.inductiveautomation.rm.archiver.RMJSONNode
-
public class RMJSONNode extends java.lang.Object
Represents a node in a JSON tree.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RMJSONNode.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 RMJSONNode
get(int anIndex)
Returns the individual node at given index.RMJSONNode
get(java.lang.String aKey)
Returns value for key if node type Map.java.lang.Boolean
getBoolean()
Returns the value as Map if type is Map.protected RMJSONNode
getJSON(java.lang.Object anObj)
Returns a JSON node of given value.java.util.List<java.lang.String>
getKeys()
Returns keys list.java.util.List
getList()
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.Object
getNonJSON()
Converts a JSON object to Map.java.lang.Number
getNumber()
Returns the value as Number if type is Number.java.lang.String
getString()
Returns the value as String if type is String.RMJSONNode.Type
getType()
Returns the the node type.java.lang.Object
getValue()
Returns the value.static void
main(java.lang.String[] args)
Simple main implementation to read standard in and re-print JSON.RMJSONNode
put(java.lang.String aKey, java.lang.Object aValue)
Sets value for key.static RMJSONNode
readSource(java.lang.Object aSource)
Creates a JSON node tree from a JSON string or JSON String byte source.protected void
setType(RMJSONNode.Type aType)
Sets the node type.protected RMJSONNode
setValue(java.lang.Object anObj)
Sets the value.int
size()
Returns the number of JSON nodes if node type List.java.lang.String
toString()
Returns a string representation of node (as JSON, of course).java.lang.String
toStringCompacted()
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:
toString
in 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.
-
-