FasterXML / FasterXML/jackson-dataformats-binary

'Any' type not supported as a type by protobuf

Ouverte
#199 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
protobuf
Langage dominant
Java
Étoiles
347
Forks
156
Merge moyen
3 j 3 h
PR mergées (30 j)
22

Description

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?

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.