public static void writeArrayAsJson(JsonGenerator generator, Object value, String pdxField)
      throws IOException {

    if (!value.getClass().isArray()) {
      throw new IllegalStateException(
          "Expected an array for pdx field " + pdxField + ", but got an object of type "
              + value.getClass());
    } else if (value.getClass().getName().equals("[Z")) {
      writePrimitiveBoolArrayAsJson(generator, (boolean[]) value);
    } else if (value.getClass().getName().equals("[B")) {
      writePrimitiveByteArrayAsJson(generator, (byte[]) value);
    } else if (value.getClass().getName().equals("[S")) {
      writePrimitiveShortArrayAsJson(generator, (short[]) value);
    } else if (value.getClass().getName().equals("[I")) {
      writePrimitiveIntArrayAsJson(generator, (int[]) value);
    } else if (value.getClass().getName().equals("[J")) {
      writePrimitiveLongArrayAsJson(generator, (long[]) value);
    } else if (value.getClass().getName().equals("[F")) {
      writePrimitiveFloatArrayAsJson(generator, (float[]) value);
    } else if (value.getClass().getName().equals("[D")) {
      writePrimitiveDoubleArrayAsJson(generator, (double[]) value);
    } else if (value.getClass().equals(Boolean[].class)) {
      writeWrapperBoolArrayAsJson(generator, (Boolean[]) value);
    } else if (value.getClass().equals(Byte[].class)) {
      writeWrapperByteArrayAsJson(generator, (Byte[]) value);
    } else if (value.getClass().equals(Short[].class)) {
      writeWrapperShortArrayAsJson(generator, (Short[]) value);
    } else if (value.getClass().equals(Integer[].class)) {
      writeWrapperIntArrayAsJson(generator, (Integer[]) value);
    } else if (value.getClass().equals(Long[].class)) {
      writeWrapperLongArrayAsJson(generator, (Long[]) value);
    } else if (value.getClass().equals(Float[].class)) {
      writeWrapperFloatArrayAsJson(generator, (Float[]) value);
    } else if (value.getClass().equals(Double[].class)) {
      writeWrapperDoubleArrayAsJson(generator, (Double[]) value);
    } else if (value.getClass().equals(BigInteger[].class)) {
      writeBigIntArrayAsJson(generator, (BigInteger[]) value);
    } else if (value.getClass().equals(BigDecimal[].class)) {
      writeBigDecimalArrayAsJson(generator, (BigDecimal[]) value);
    } else if (value.getClass().equals(String[].class)) {
      writeStringArrayAsJson(generator, (String[]) value);
    } else if (value.getClass().equals(Object[].class)) {
      writeObjectArrayAsJson(generator, (Object[]) value, pdxField);
    } else {
      throw new IllegalStateException(
          "The pdx field " + pdxField + " is an array whose component type "
              + value.getClass().getComponentType()
              + " can not be converted to JSON.");
    }
  }
The JsonWriter class is an utility to write various java types as a JSON string.
<p>

@since GemFire 8.0
geode-web-api/src/main/java/org/apache/geode/rest/internal/web/util/JsonWriter.java