Class JsonObject

java.lang.Object
org.apache.jackrabbit.oak.commons.json.JsonObject

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

    • 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 Details

    • fromJson

      public static JsonObject fromJson(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 Map<String,String> getProperties()
      Get the (mutable) map of properties.
      Returns:
      the property map
    • getChildren

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

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