Java Utililty Methods Json Get

List of utility methods to do Json Get

Description

The list of methods to do Json Get are organized into topic(s).

Method

booleangetBoolean(JsonObject json, String name)
Returns the value for the specified parameter name included in the specified json object.
return (json != null && json.containsKey(name)) && json.getBoolean(name);
BooleangetBooleanValue(JsonValue value)
Convert a JsonValue into a equivalent Java Boolean.
switch (value.getValueType()) {
case TRUE:
    return true;
case FALSE:
    return false;
default:
    throw new ClassCastException();
JsonBuilderFactorygetBuilderFactory()
get Builder Factory
Map<String, Object> config = new HashMap<String, Object>();
return Json.createBuilderFactory(config);
intgetInt(JsonObject json, String name)
Returns the value for the specified parameter name included in the specified json object.
return (json != null && json.containsKey(name)) ? json.getInt(name) : -1;
int[]getIntArray(JsonObject object, String name)
get Int Array
return toIntArray(getJsonArray(object, name));
ArrayListgetIntegerArrayList(JsonArray array)
get Integer Array List
ArrayList<Integer> res = new ArrayList<Integer>(array.size());
for (JsonValue v : array) {
    res.add(((JsonNumber) v).intValue());
return res;
ArrayListgetIntegerArrayListSansDoublons(JsonArray array)
get Integer Array List Sans Doublons
ArrayList<Integer> resDoublons = getIntegerArrayList(array);
HashSet<Integer> set = new HashSet<Integer>(resDoublons.size());
set.addAll(resDoublons);
return new ArrayList<Integer>(set);
JsonArraygetJsonArray(JsonObject object, String name)
get Json Array
if (hasKey(object, name)) {
    return object.getJsonArray(name);
return null;
JsonArraygetJsonIntArray(Iterable integers)
get Json Int Array
JsonArrayBuilder builder = Json.createArrayBuilder();
for (int i : integers) {
    builder.add(i);
return builder.build();
JsonNumbergetJsonNumberOrNull(JsonObject object, String key)
get Json Number Or Null
return object.containsKey(key) && !object.isNull(key) ? object.getJsonNumber(key) : null;