public static void writeQueryListAsJson(JsonGenerator generator, String pdxField,
      Region<String, String> region) throws IOException {
    generator.writeStartObject();
    generator.writeFieldName(pdxField);

    generator.writeStartArray();

    for (Map.Entry<String, String> entry : region.entrySet()) {
      generator.writeStartObject();

      generator.writeFieldName("id");
      generator.writeString(entry.getKey());

      generator.writeFieldName("oql");
      generator.writeString(entry.getValue());

      generator.writeEndObject();
    }

    generator.writeEndArray();
    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