Package nxt.addons

Class JO

All Implemented Interfaces:
Map

public class JO extends AbstractMap
Delegate json object operations to json simple and wrap it with convenience methods This class does not really keep a map, but it implements a map in order to delegate entrySet to the underlying JSONArray in order to support streaming into String.
  • Constructor Details

    • JO

      public JO()
    • JO

      public JO(org.json.simple.JSONObject jo)
    • JO

      public JO(Object obj)
  • Method Details

    • toJSONObject

      public org.json.simple.JSONObject toJSONObject()
    • put

      public void put(String key, Object o)
    • put

      public Object put(Object key, Object o)
      Specified by:
      put in interface Map
      Overrides:
      put in class AbstractMap
    • getArray

      public JA getArray(String key)
    • getJoList

      public List<JO> getJoList(String key)
    • valueOf

      public static JO valueOf(Object o)
    • valueOf

      public static JO valueOf(JO o)
    • parse

      public static JO parse(String s)
    • parse

      public static JO parse(Reader r)
    • get

      public Object get(String key)
    • getJo

      public JO getJo(String key)
    • getEntityId

      public long getEntityId(String key)
    • entrySet

      public Set<Map.Entry> entrySet()
      Specified by:
      entrySet in interface Map
      Specified by:
      entrySet in class AbstractMap
    • toJSONString

      public String toJSONString()
    • getLong

      public long getLong(String key, long defaultValue)
    • getLong

      public long getLong(String key)
    • getInt

      public int getInt(String key, int defaultValue)
    • getInt

      public int getInt(String key)
    • getDouble

      public double getDouble(String key, double defaultValue)
    • getDouble

      public double getDouble(String key)
    • getFloat

      public float getFloat(String key, float defaultValue)
    • getFloat

      public float getFloat(String key)
    • getShort

      public short getShort(String key, short defaultValue)
    • getShort

      public short getShort(String key)
    • getByte

      public byte getByte(String key, byte defaultValue)
    • getByte

      public byte getByte(String key)
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
    • getBoolean

      public boolean getBoolean(String key)
    • getString

      public String getString(String key, String defaultValue)
    • getString

      public String getString(String key)
    • parseHexString

      public byte[] parseHexString(String key)
    • isExist

      public boolean isExist(String key)
    • copy

      public static JO copy(JO jo)
      Returns a non-deep copy of the provided JO.
      Parameters:
      jo - JSON object
      Returns:
      Copied object
    • unmodifiable

      public static JO unmodifiable(JO jo)
      Returns an unmodifiable version of a JSON object. The result is not deeply unmodifiable - sub-objects or sub-arrays can be modified.
      Parameters:
      jo - The JO to make unmodifiable
      Returns:
      An unmodifiable JO with same content as the provided JO