Class RMJSONNode

java.lang.Object
com.inductiveautomation.rm.archiver.RMJSONNode

public class RMJSONNode extends Object
Represents a node in a JSON tree.
  • Constructor Details

    • RMJSONNode

      public RMJSONNode()
      Creates a new node.
    • RMJSONNode

      public RMJSONNode(Object aSource)
      Creates a new node.
  • Method Details

    • readSource

      public static RMJSONNode readSource(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 Object getValue()
      Returns the value.
    • setValue

      protected RMJSONNode setValue(Object anObj)
      Sets the value.
    • get

      public RMJSONNode get(String aKey)
      Returns value for key if node type Map.
    • put

      public RMJSONNode put(String aKey, Object aValue)
      Sets value for key.
    • getKeys

      public List<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(Object anObj)
      Returns a JSON node of given value.
    • getMap

      public Map<String,Object> getMap()
      Returns the value as Map if type is Map.
    • getList

      public List getList()
      Returns the value as List if type is List.
    • getString

      public String getString()
      Returns the value as String if type is String.
    • getNumber

      public Number getNumber()
      Returns the value as Number if type is Number.
    • getBoolean

      public Boolean getBoolean()
      Returns the value as Map if type is Map.
    • getNonJSON

      public Object getNonJSON()
      Converts a JSON object to Map.
    • toString

      public String toString()
      Returns a string representation of node (as JSON, of course).
      Overrides:
      toString in class Object
    • toStringCompacted

      public String toStringCompacted()
      Returns a string representation of node (as JSON, of course).
    • main

      public static void main(String[] args)
      Simple main implementation to read standard in and re-print JSON.