java.lang.Object
com.grack.nanojson.JsonBuilder<T>
- Type Parameters:
T- The type of JSON object to build.
- All Implemented Interfaces:
JsonSink<JsonBuilder<T>>
Builds a
JsonObject or JsonArray.-
Method Summary
Modifier and TypeMethodDescriptionarray()Starts an array.Starts an array within an object, prefixed with a key.array(String key, Collection<?> c) Emits the start of an array with a key.array(Collection<?> c) Emits the start of an array.done()Completes this builder, closing any unclosed objects and returns the built object.end()Ends the current array or object.Writes the key of a key/value pair.nul()Emits a 'null' token.Emits a 'null' token with a key.object()Starts an object.Starts an object within an object, prefixed with a key.Emits the start of an object with a key.Emits the start of an object.value(boolean b) Emits a boolean value.value(double d) Emits a double value.value(float f) Emits a float value.value(int i) Emits an integer value.value(long l) Emits a long value.Emits aNumbervalue.Emits an object if it is a JSON-compatible type, otherwise throws an exception.Emits a string value (or null).Emits a boolean value with a key.Emits a double value with a key.Emits a float value with a key.Emits an integer value with a key.Emits a long value with a key.Emits aNumbervalue with a key.Emits an object with a key if it is a JSON-compatible type, otherwise throws an exception.Emits a string value (or null) with a key.
-
Method Details
-
done
Completes this builder, closing any unclosed objects and returns the built object. -
array
Description copied from interface:JsonSinkEmits the start of an array. -
array
Description copied from interface:JsonSinkEmits the start of an array with a key. -
object
Description copied from interface:JsonSinkEmits the start of an object. -
object
Description copied from interface:JsonSinkEmits the start of an object with a key. -
nul
Description copied from interface:JsonSinkEmits a 'null' token. -
nul
Description copied from interface:JsonSinkEmits a 'null' token with a key. -
value
Description copied from interface:JsonSinkEmits an object if it is a JSON-compatible type, otherwise throws an exception. -
value
Description copied from interface:JsonSinkEmits an object with a key if it is a JSON-compatible type, otherwise throws an exception. -
value
Description copied from interface:JsonSinkEmits a string value (or null). -
value
Description copied from interface:JsonSinkEmits an integer value. -
value
Description copied from interface:JsonSinkEmits a long value. -
value
Description copied from interface:JsonSinkEmits a boolean value. -
value
Description copied from interface:JsonSinkEmits a double value. -
value
Description copied from interface:JsonSinkEmits a float value. -
value
Description copied from interface:JsonSinkEmits aNumbervalue. -
value
Description copied from interface:JsonSinkEmits a string value (or null) with a key. -
value
Description copied from interface:JsonSinkEmits an integer value with a key. -
value
Description copied from interface:JsonSinkEmits a long value with a key. -
value
Description copied from interface:JsonSinkEmits a boolean value with a key. -
value
Description copied from interface:JsonSinkEmits a double value with a key. -
value
Description copied from interface:JsonSinkEmits a float value with a key. -
value
Description copied from interface:JsonSinkEmits aNumbervalue with a key. -
array
Description copied from interface:JsonSinkStarts an array. -
object
Description copied from interface:JsonSinkStarts an object. -
array
Description copied from interface:JsonSinkStarts an array within an object, prefixed with a key. -
object
Description copied from interface:JsonSinkStarts an object within an object, prefixed with a key. -
end
Description copied from interface:JsonSinkEnds the current array or object. -
key
Description copied from interface:JsonSinkWrites the key of a key/value pair.
-