Java Json Get getJsonArray(JsonObject object, String name)

Here you can find the source of getJsonArray(JsonObject object, String name)

Description

get Json Array

License

Open Source License

Declaration

public static JsonArray getJsonArray(JsonObject object, String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.json.JsonArray;

import javax.json.JsonObject;

import javax.json.JsonValue;

public class Main {
    public static JsonArray getJsonArray(JsonObject object, String name) {
        if (hasKey(object, name)) {
            return object.getJsonArray(name);
        }/*from   ww  w .j a  v  a 2s  . c o  m*/
        return null;
    }

    public static JsonArray getJsonArray(JsonArray object, int index) {
        if (object == null)
            return null;
        if (object.size() <= index)
            return null;
        JsonValue value = object.get(index);
        if ((value == null) || (value == JsonValue.NULL)) {
            return null;
        }
        return object.getJsonArray(index);
    }

    public static boolean hasKey(JsonObject object, String name) {
        JsonValue value = object.get(name);
        if ((value == null) || (value == JsonValue.NULL)) {
            return false;
        }
        return true;
    }
}

Related

  1. getBuilderFactory()
  2. getInt(JsonObject json, String name)
  3. getIntArray(JsonObject object, String name)
  4. getIntegerArrayList(JsonArray array)
  5. getIntegerArrayListSansDoublons( JsonArray array)
  6. getJsonIntArray(Iterable integers)
  7. getJsonNumberOrNull(JsonObject object, String key)
  8. getJsonObject(JsonObject object, String name)
  9. getJsonValue(String json_path, JsonObject response)