public static void writeLinkAsJson(JsonGenerator generator, Link value, String pdxField)
      throws IOException {
    generator.writeArrayFieldStart("links");

    generator.writeStartObject();

    generator.writeFieldName("rel");
    generator.writeString(value.getRel().value());

    generator.writeFieldName("href");
    generator.writeString(value.getHref());

    generator.writeFieldName("type");

    HttpHeaders header = new HttpHeaders();
    header.setContentType(MediaType.APPLICATION_JSON);
    List<Charset> arg = new ArrayList<>();
    arg.add(Charset.defaultCharset());
    header.setAcceptCharset(arg);

    generator.writeString(
        header.getContentType() + ", charset=" + header.getAcceptCharset().get(0).displayName());

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