Builds a {@link JsonObject} from scratch. It uses builder pattern to buildthe object model and the builder methods can be chained while building the JSON Object.
For example, for the following JSON
{ "firstName": "John", "lastName": "Smith", "age": 25, "address" : { "streetAddress", "21 2nd Street", "city", "New York", "state", "NY", "postalCode", "10021" }, "phoneNumber": [ { "type": "home", "number": "212 555-1234" }, { "type": "fax", "number": "646 555-4567" } ] }
a JsonObject instance can be built using:
JsonObject value = new JsonObjectBuilder() .add("firstName", "John") .add("lastName", "Smith") .add("age", 25) .add("address", new JsonObjectBuilder() .add("streetAddress", "21 2nd Street") .add("city", "New York") .add("state", "NY") .add("postalCode", "10021")) .add("phoneNumber", new JsonArrayBuilder() .add(new JsonObjectBuilder() .add("type", "home") .add("number", "212 555-1234")) .add(new JsonObjectBuilder() .add("type", "fax") .add("number", "646 555-4567"))) .build();
@see JsonArrayBuilder