Class JsonObject


  • public class JsonObject
    extends java.lang.Object
    Simple JSON Object representation. It optionally supports respecting the order of properties, and the order children.
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonObject()
      Create a Json object that doesn't respect the order.
      JsonObject​(boolean respectOrder)
      Create a Json object.
    • Constructor Detail

      • JsonObject

        public JsonObject()
        Create a Json object that doesn't respect the order.
      • JsonObject

        public JsonObject​(boolean respectOrder)
        Create a Json object.
        Parameters:
        respectOrder - whether the object should respect the order
    • Method Detail

      • fromJson

        public static JsonObject fromJson​(java.lang.String json,
                                          boolean respectOrder)
        Build a Json object from a String.
        Parameters:
        json - the json string
        respectOrder - whether the object should respect the child order
        Returns:
        the json object
      • create

        public static JsonObject create​(JsopTokenizer t,
                                        boolean respectOrder)
        Reads a JSON object from the given tokenizer. The opening '{' of the object should already have been consumed from the tokenizer before this method is called.
        Parameters:
        t - tokenizer
        respectOrder - whether the order should be respected
        Returns:
        JSON object
      • create

        public static JsonObject create​(JsopTokenizer t)
        Reads a JSON object from the given tokenizer. The opening '{' of the object should already have been consumed from the tokenizer before this method is called.
        Parameters:
        t - tokenizer
        Returns:
        JSON object
      • toJson

        public void toJson​(JsopBuilder buf)
        Write the object to a builder.
        Parameters:
        buf - the target
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.String> getProperties()
        Get the (mutable) map of properties.
        Returns:
        the property map
      • getChildren

        public java.util.Map<java.lang.String,​JsonObject> getChildren()
        Get the (mutable) map of children.
        Returns:
        the children map
      • toString

        public java.lang.String toString()
        Pretty-print the object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the pretty-printed string representation