public static void write(Message message, JsonWriter writer) {
    writer.setSerializeNulls(false).setSerializeEmptys(true);
    writer.beginObject();
    writeMessage(message, writer);
    writer.endObject();
  }
@Test
  public void bytes_field_can_not_be_converted() {
    assertThatThrownBy(() -> {
      PrimitiveTypeMsg protobuf = PrimitiveTypeMsg.newBuilder()
        .setBytesField(ByteString.copyFrom(new byte[]{2, 4}))
        .build();

      ProtobufJsonFormat.write(protobuf, JsonWriter.of(new StringWriter()));
    })
      .isInstanceOf(RuntimeException.class)
      .hasMessage("JSON format does not support type 'BYTE_STRING' of field 'bytesField'");
  }