FasterXML / FasterXML/jackson-dataformats-binary

'Any' type not supported as a type by protobuf

未關閉
#199 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
protobuf
主要語言
Java
星號
347
分支
156
平均合併
3 天 3 小時
30 天內合併 PR
22

描述

Hi! I have the below generic object that I use as a wrapper around other objects when sending a response.

```
public class Response {
private T data;

public Response() {

}

public T getData() {
return data;
}

public void setData(T data) {
this.data = data;
}
}
```

When I try to generate a byte buffer from the `Response` object with the below code I receive the error, _'Any' type not supported as a type by protobuf_

```
ObjectMapper mapper = new ObjectMapper(new ProtobufFactory());
ProtobufSchemaGenerator generator = new ProtobufSchemaGenerator();
mapper.acceptJsonFormatVisitor(Response.class, generator);
ProtobufSchema schema = generator.getGeneratedSchema();

Response response = new Response<>();

byte[] bytes = mapper.writer(schema).writeValueAsBytes(response);
ByteBuffer buffer = ByteBuffer.wrap(bytes);

session.sendMessage(new BinaryMessage(buffer));
```

Are generics not supported? Would there be an alternative to this generics approach?

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。