Get a {@link JSONArray} from a {@link JSONValue}.  Return {@code null} if the
{@link JSONValue} is {@code null}.

@param   value   the {@link JSONValue}
@return  the value as a {@link JSONArray}
@throws  JSONException if the value is not an array
518219
public static JSONArray getArray(JSONValue value) {
        if (value == null)
            return null;
        if (!(value instanceof JSONArray))
            throw new JSONException(NOT_AN_ARRAY);
        return (JSONArray)value;
    }
888761
public static boolean getBoolean(JSONValue value) {
        if (value == null)
            return false;
        if (!(value instanceof JSONBoolean))
            throw new JSONException(NOT_A_BOOLEAN);
        return ((JSONBoolean)value).booleanValue();
    }
1222082
public JsonArray add(Object value) {
        if (value == this) {
            throw new IllegalArgumentException("Cannot add self");
        } else if (value == JsonValue.NULL) {
            addNull();
        } else if (checkType(value)) {
            content.add(value);
        } else {
            throw new IllegalArgumentException("Unsupported type for JsonArray: " + value.getClass());
        }
        return this;
    }
1367776
static JsonArray getArrayFromJsonElement(JsonElement jsonElement) {
        JsonArray jsonArray = null;
        if (jsonElement.isJsonArray()) {
            jsonArray = jsonElement.getAsJsonArray();
        } else if (jsonElement.isJsonObject() &&
                ((JsonObject) jsonElement).get("results") != null &&
                ((JsonObject) jsonElement).get("results").isJsonArray()) {
            jsonArray = ((JsonObject) jsonElement).get("results").getAsJsonArray();
        }
        return jsonArray;
    }
403970
public JsonWriter value(@NonNull Iterable<?> value) throws IOException {
      Preconditions.checkArgument(inArray() || writeStack.peek() == JsonTokenType.NAME,
                                  "Expecting an array or a name, but found " + writeStack.peek());
      popIf(JsonTokenType.NAME);
      beginArray();
      for (Object o : value) {
         value(o);
      }
      endArray();
      return this;
   }
176121
public static long getLong(JSONValue value) {
        if (value == null)
            return 0;
        if (!(value instanceof Number))
            throw new JSONException(NOT_A_NUMBER);
        return ((Number)value).longValue();
    }
107658
public static JsonArray getArray(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asArray();
    }
1087148
@Nullable
    static List<Object> jsonArrayToList(@Nullable JSONArray jsonArray) {
        if (jsonArray == null) {
            return null;
        }

        List<Object> objectList = new ArrayList<>();
        for (int i = 0; i < jsonArray.length(); i++) {
            try {
                Object ob = jsonArray.get(i);
                if (ob instanceof JSONArray) {
                    objectList.add(jsonArrayToList((JSONArray) ob));
                } else if (ob instanceof JSONObject) {
                    Map<String, Object> objectMap = jsonObjectToMap((JSONObject) ob);
                    if (objectMap != null) {
                        objectList.add(objectMap);
                    }
                } else {
                    if (NULL.equals(ob)) {
                        continue;
                    }
                    objectList.add(ob);
                }
            } catch (JSONException ignored) {
                // Nothing to do in this case.
            }
        }
        return objectList;
    }
1230831
private JSONValue toJsonStringList(Collection<? extends Object> list) {

        if (null != list) {
            JSONArray array = new JSONArray();
            for (Object o : list) {
                array.set(array.size(), new JSONString(o.toString()));
            }
            return array;
        } else {
            return null;
        }
    }
833880
static javax.json.JsonValue map(final JsonValue jsonValue) {
        if (jsonValue instanceof JsonArray)
            return map((JsonArray) jsonValue);
        return map((JsonObject) jsonValue);
    }
155517
private JsonElement convertValue(String value, JsonObject dataType) {
    if (dataType == null || !dataType.has(TYPE)) {
      return new JsonPrimitive(value);
    }

    String type = dataType.get(TYPE).getAsString().toUpperCase();
    ValueType valueType = ValueType.valueOf(type);
    return valueType.convert(value);
  }
1361682
public JsonArray toJsonArray(JsonArray names) throws JsonException {
        JsonArray result = new JsonArray();
        if (names == null) {
            return null;
        }
        int length = names.length();
        if (length == 0) {
            return null;
        }
        for (int i = 0; i < length; i++) {
            String name = Util.toString(names.opt(i));
            result.put(opt(name));
        }
        return result;
    }
967573
public static String[] getStringArray(
    Object  value) throws ParseException
  {
    if (value == null)
    {
        return null;
    }

    return getTokensArray(value.toString());
  }
1183801
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static List<Object> arrayAsList(Object value) {
		if (value instanceof List) {
			return (List<Object>) value;
		}
		List list = null;
		if (value instanceof int[]) {
			list = new ArrayList();
			int[] array = (int[]) value;
			for (int i : array) {
				list.add(i);
			}
		} else if (value instanceof short[]) {
			list = new ArrayList();
			short[] array = (short[]) value;
			for (short i : array) {
				list.add(i);
			}
		} else if (value instanceof char[]) {
			list = new ArrayList();
			char[] array = (char[]) value;
			for (char i : array) {
				list.add(i);
			}
		} else if (value instanceof byte[]) {
			list = new ArrayList();
			byte[] array = (byte[]) value;
			for (byte i : array) {
				list.add(i);
			}
		} else if (value instanceof long[]) {
			list = new ArrayList();
			long[] array = (long[]) value;
			for (long i : array) {
				list.add(i);
			}
		} else if (value instanceof double[]) {
			list = new ArrayList();
			double[] array = (double[]) value;
			for (double i : array) {
				list.add(i);
			}
		} else if (value instanceof float[]) {
			list = new ArrayList();
			float[] array = (float[]) value;
			for (float i : array) {
				list.add(i);
			}
		} else if (value instanceof boolean[]) {
			list = new ArrayList();
			boolean[] array = (boolean[]) value;
			for (boolean i : array) {
				list.add(i);
			}
		} else if (value.getClass().isArray()) {
			Object[] array = (Object[]) value;
			list = Arrays.asList(array);
		}
		return list;
	}
984622
public static float getFloat(JSONValue value) {
        if (value == null)
            return 0;
        if (!(value instanceof Number))
            throw new JSONException(NOT_A_NUMBER);
        return ((Number)value).floatValue();
    }
184238
public static Instant parseJsonDate(String value) {
        if (value == null) {
            return null;
        }
        return LocalDateTime.parse(value, JSON_DATETIME_FORMAT).atOffset(ZoneOffset.UTC).toInstant();
    }
107709
private static String getJsonValueAsNumberString(JsonValue value) {
        return (value != null && value.getValueType() == ValueType.NUMBER) ? value.toString() : null;
    }