Class JsonBuilder

  • public class JsonBuilder
    extends java.lang.Object
    • Constructor Detail

      • JsonBuilder

        public JsonBuilder()
    • Method Detail

      • createFrom

        public static JsonBuilder createFrom​(JsonValue arg)
        Create a builder from a JsonValue.

        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

        public static JsonValue copy​(JsonValue arg)
        Create a safe copy of a JsonValue.

        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

        public static JsonObject buildObject​(java.util.function.Consumer<JsonBuilder> setup)
        Build a JsonObject. The outer object is created and then the setup function called to fill in the contents.
             builder.pair("key", 1234);
        setup -
      • reset

        public void reset()
      • startObject

        public JsonBuilder startObject​(java.lang.String startMarker)
      • finishObject

        public JsonBuilder finishObject​(java.lang.String finishMarker)
      • pair

        public JsonBuilder pair​(java.lang.String key,
                                boolean value)
      • pair

        public JsonBuilder pair​(java.lang.String key,
                                java.math.BigDecimal value)
      • pair

        public JsonBuilder pair​(java.lang.String key,
                                double value)
      • pair

        public JsonBuilder pair​(java.lang.String key,
                                long value)
      • pair

        public JsonBuilder pair​(java.lang.String key,
                                java.lang.String value)
      • key

        public JsonBuilder key​(java.lang.String key)
      • value

        public JsonBuilder value​(java.math.BigDecimal decimal)
      • value

        public JsonBuilder value​(java.lang.String string)