'Spring missing field when usingprotobuf JsonFormat.printer
I will made JsonSerializer
public class ProtobufSerializer extends JsonSerializer<Message> {
private final JsonFormat.Printer printer = JsonFormat.printer().preservingProtoFieldNames();
@Override
public void serialize(Message protoMessage, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException {
String print = printer.print(protoMessage);
jsonGenerator.writeRawValue(print);
}
}
when i get protoMessage value like it this enter image description here
{
result_ = true
code_ = 0
message_ = ""
}
but code and message field is missing after this method
String print = printer.print(protoMessage);
how can i prevent missing field?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
