public static void writeRegionDetailsAsJson(JsonGenerator generator, Region<?, ?> region)
      throws IOException {
    generator.writeStartObject();

    generator.writeFieldName("name");
    generator.writeString(region.getName());

    generator.writeFieldName("type");

    if (region.getAttributes().getDataPolicy() != null) {
      generator.writeString(region.getAttributes().getDataPolicy().toString());
    } else {
      generator.writeNull();
    }

    generator.writeFieldName("key-constraint");
    if (region.getAttributes().getKeyConstraint() != null) {
      generator.writeString(region.getAttributes().getKeyConstraint().getName());
    } else {
      generator.writeNull();
    }

    generator.writeFieldName("value-constraint");
    if (region.getAttributes().getValueConstraint() != null) {
      generator.writeString(region.getAttributes().getValueConstraint().getName());
    } else {
      generator.writeNull();
    }

    generator.writeEndObject();

  }
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