public static void writeQueryAsJson(JsonGenerator generator, String queryId, String query)
      throws IOException {
    generator.writeStartObject();

    generator.writeFieldName("id");
    generator.writeString(queryId);

    generator.writeFieldName("oql");
    generator.writeString(query);

    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