java.lang.Object
org.apache.jena.atlas.json.JsonBuilder
Builder pattern for JSON.
The JsonValue built can be an array or object at the outmost level, but not an atomic value.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()static JsonObjectbuildObject(Consumer<JsonBuilder> setup) Build a JsonObject.static JsonValueCreate a safe copy of aJsonValue.static JsonBuildercreate()static JsonBuildercreateFrom(JsonValue arg) Create a builder from aJsonValue.finishObject(String finishMarker) pair(String key, BigDecimal value) voidreset()startObject(String startMarker) value(boolean b) value(double d) value(long val) value(BigDecimal decimal)
-
Constructor Details
-
JsonBuilder
public JsonBuilder()
-
-
Method Details
-
create
-
createFrom
Create a builder from aJsonValue.If the argument is an object or array, use it to initialize the builder.
If the argument is a JSON primitive (string, number, boolean or null),
Otherwise thrown
IllegalArgumentException. -
copy
Create a safe copy of aJsonValue.If the JsonValue is a structure (object or array), copy the structure recursively.
If the JsonValue is a primitive (string, number, boolean or null), it is immutable so return the same object.
-
buildObject
Build a JsonObject. The outer object is created and then thesetupfunction called to fill in the contents.buildObject(builder->{ builder.pair("key", 1234); });- Parameters:
setup-- Returns:
- JsonObject
-
build
-
reset
public void reset() -
startObject
-
startObject
-
finishObject
-
finishObject
-
startArray
-
finishArray
-
pair
-
pair
-
pair
-
pair
-
pair
-
pair
-
key
-
remove
-
value
-
value
-
value
-
value
-
value
-
valueNull
-
value
-