jakartaee / jsonp-api

Jakarta JSON Processing
https://eclipse.org/ee4j/jsonp
Other
141 stars 61 forks source link

Provide methods for inspection of JsonObjectBuilder #179

Open ivangreene opened 5 years ago

ivangreene commented 5 years ago

At times, it may be useful to inspect a JsonObjectBuilder without needing to build it (such as determining whether or not the object contains a particular key, for example). Methods could be provided on JsonObjectBuilder to examine the state of the underlying JsonObject to be built

ivangreene commented 5 years ago

See #178 for some background on the reason for this: currently, to inspect a JsonObjectBuilder while still adding values to it, one must do something such as the following to obtain a JsonObject to inspect values of:

    public static JsonObject buildWithoutClearing(JsonObjectBuilder jsonObjectBuilder) {
        JsonObject built = jsonObjectBuilder.build();
        JsonObjectBuilder clone = Json.createObjectBuilder(built);
        jsonObjectBuilder.addAll(clone);
        return built;
    }