### Question:
JsonObjectBuilderImpl implements JsonObjectBuilder, Serializable { @Override public JsonObject build() { if(attributeMap == null || attributeMap.isEmpty()) { return JsonValue.EMPTY_JSON_OBJECT; } else { Map<String, JsonValue> dump = (Collections.unmodifiableMap(attributeMap)); return new JsonObjectImpl(dump, bufferProvider); } } protected  JsonObjectBuilderImpl();  JsonObjectBuilderImpl(final JsonObject initialData,
                                 final BufferStrategy.BufferProvider<char[]> bufferProvider);  JsonObjectBuilderImpl(final Map<String, Object> initialValues,
                                 final BufferStrategy.BufferProvider<char[]> bufferProvider); void add(final String name, final Object value); @Override JsonObjectBuilder add(final String name, final JsonValue value); @Override JsonObjectBuilder add(final String name, final String value); @Override JsonObjectBuilder add(final String name, final BigInteger value); @Override JsonObjectBuilder add(final String name, final BigDecimal value); @Override JsonObjectBuilder add(final String name, final int value); @Override JsonObjectBuilder add(final String name, final long value); @Override JsonObjectBuilder add(final String name, final double value); @Override JsonObjectBuilder add(final String name, final boolean value); @Override JsonObjectBuilder addNull(final String name); @Override JsonObjectBuilder add(final String name, final JsonObjectBuilder builder); @Override JsonObjectBuilder add(final String name, final JsonArrayBuilder builder); @Override JsonObjectBuilder addAll(JsonObjectBuilder builder); @Override JsonObjectBuilder remove(String name); @Override JsonObject build();  }### Answer:
@Test public void createObjectBuilderMapSupport() { final Map<String, Object> initial = new HashMap<>(); initial.put("a", "b"); initial.put("c", singletonMap("d", "e")); initial.put("f", singleton("g")); final JsonObject build = Json.createObjectBuilder(initial).build(); assertEquals("{\"a\":\"b\",\"c\":{\"d\":\"e\"},\"f\":[\"g\"]}", build.toString()); }
@Test public void testBuild() { final JsonObjectBuilder builder = Json.createObjectBuilder(); builder.add("a", "b"); JsonObject jsonObject = builder.build(); assertEquals("{\"a\":\"b\"}", jsonObject.toString()); JsonObjectBuilder anotherBuilder = Json.createObjectBuilder(jsonObject); anotherBuilder.add("c", "d"); assertEquals("{\"a\":\"b\",\"c\":\"d\"}", anotherBuilder.build().toString()); }
@Test public void testCreateObjectBuilderWithMapFlatItems() { Map<String, Object> jsonItems = new HashMap<>(); { jsonItems.put("bigDecimalVal", new BigDecimal(1234567.89)); jsonItems.put("bigIntegerVal", BigInteger.valueOf(54321L)); jsonItems.put("booleanVal", true); jsonItems.put("doubleVal", 1234567.89d); jsonItems.put("intVal", 4711); jsonItems.put("jsonValueVal", JsonValue.FALSE); jsonItems.put("longVal", 123_456_789L); jsonItems.put("stringVal", "b"); jsonItems.put("nullVal", null); Assert.assertEquals(9, jsonItems.size()); } JsonObjectBuilder builder = Json.createObjectBuilder(jsonItems); JsonObject jsonObject = builder.build(); Assert.assertEquals(new BigDecimal(1234567.89), jsonObject.getJsonNumber("bigDecimalVal").bigDecimalValue()); Assert.assertEquals(BigInteger.valueOf(54321L), jsonObject.getJsonNumber("bigIntegerVal").bigIntegerValue()); Assert.assertEquals(true, jsonObject.getBoolean("booleanVal")); Assert.assertEquals(1234567.89d, jsonObject.getJsonNumber("doubleVal").doubleValue(), 0.01d); Assert.assertEquals(4711, jsonObject.getInt("intVal")); Assert.assertEquals(JsonValue.FALSE, jsonObject.get("jsonValueVal")); Assert.assertEquals(123_456_789L, jsonObject.getJsonNumber("longVal").longValue()); Assert.assertEquals("b", jsonObject.getString("stringVal")); Assert.assertEquals(true, jsonObject.isNull("nullVal")); }