code: public static void tagToJson(JsonGenerator gen, Tag tag) throws IOException {
      final String key = tag.getKey();
      if (RELAXED_GROUP_KEYS.contains(key)) {
        gen.writeStringField(key, toValidCharsetTable(CHARS_ALLOWED_GROUPS, tag.getValue()));
      } else {
        gen.writeStringField(toValidCharset(tag.getKey()), toValidCharset(tag.getValue()));
      }
    }
docs: Serialize a tag to the given JsonGenerator.