jsonp-api icon indicating copy to clipboard operation
jsonp-api copied to clipboard

Provide methods for inspection of JsonObjectBuilder

Open ivangreene opened this issue 5 years ago • 1 comments

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 avatar Jun 05 '19 17:06 ivangreene

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;
    }

ivangreene avatar Jun 05 '19 17:06 ivangreene