public class JsonBuilder extends Object
For example, {"a": {"b": true, "c": [1.0,2.0,3.0]}}
can be written as:
JsonBuilder.object()
.addObject(
"a",
JsonBuilder.object()
.addBoolean("b", true)
.addArray("c", JsonBuilder.array().addNumber(1.0).addNumber(2.0).addNumber(3.0)))
.toString();
Modifier and Type | Class and Description |
---|---|
static class |
JsonBuilder.ArrayBuilder
Builder for a JSON array string.
|
static class |
JsonBuilder.ObjectBuilder
Builder for a JSON object string.
|
Modifier and Type | Method and Description |
---|---|
static JsonBuilder.ArrayBuilder |
array()
Creates a builder for a JSON array string.
|
static JsonBuilder.ArrayBuilder |
arrayOfDoubles(java.util.stream.DoubleStream numbers) |
static JsonBuilder.ObjectBuilder |
object()
Creates a builder for a JSON object string.
|
static <T> java.util.stream.Collector<T,JsonBuilder.ArrayBuilder,JsonBuilder.ArrayBuilder> |
toArray(java.util.function.BiConsumer<JsonBuilder.ArrayBuilder,T> accumulate) |
static java.util.stream.Collector<JsonBuilder.ArrayBuilder,?,JsonBuilder.ArrayBuilder> |
toArrayOfArrays() |
static java.util.stream.Collector<JsonBuilder.ObjectBuilder,?,JsonBuilder.ArrayBuilder> |
toArrayOfObjects() |
static java.util.stream.Collector<String,?,JsonBuilder.ArrayBuilder> |
toArrayOfStrings() |
public static JsonBuilder.ArrayBuilder array()
public static JsonBuilder.ObjectBuilder object()
public static JsonBuilder.ArrayBuilder arrayOfDoubles(java.util.stream.DoubleStream numbers)
public static java.util.stream.Collector<String,?,JsonBuilder.ArrayBuilder> toArrayOfStrings()
public static java.util.stream.Collector<JsonBuilder.ArrayBuilder,?,JsonBuilder.ArrayBuilder> toArrayOfArrays()
public static java.util.stream.Collector<JsonBuilder.ObjectBuilder,?,JsonBuilder.ArrayBuilder> toArrayOfObjects()
public static <T> java.util.stream.Collector<T,JsonBuilder.ArrayBuilder,JsonBuilder.ArrayBuilder> toArray(java.util.function.BiConsumer<JsonBuilder.ArrayBuilder,T> accumulate)