FasterXML / FasterXML/jackson-dataformats-binary
'Any' type not supported as a type by protobuf
- Ngôn ngữ chính
- Java
- Star
- 347
- Fork
- 156
- Merge trung bình
- 3 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 22
Mô tả
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?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.