Class JsonObject
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.json.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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonObject
create(JsopTokenizer t)
Reads a JSON object from the given tokenizer.static JsonObject
create(JsopTokenizer t, boolean respectOrder)
Reads a JSON object from the given tokenizer.static JsonObject
fromJson(java.lang.String json, boolean respectOrder)
Build a Json object from a String.java.util.Map<java.lang.String,JsonObject>
getChildren()
Get the (mutable) map of children.java.util.Map<java.lang.String,java.lang.String>
getProperties()
Get the (mutable) map of properties.void
toJson(JsopBuilder buf)
Write the object to a builder.java.lang.String
toString()
Pretty-print the object.
-
-
-
Method Detail
-
fromJson
public static JsonObject fromJson(java.lang.String json, boolean respectOrder)
Build a Json object from a String.- Parameters:
json
- the json stringrespectOrder
- 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
- tokenizerrespectOrder
- 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 classjava.lang.Object
- Returns:
- the pretty-printed string representation
-
-