-
-
Notifications
You must be signed in to change notification settings - Fork 144
Closed
Description
Jackson version: 2.9.4
I'm trying to use streaming JsonParser to parse protobuf binary data according to your example, however the nextToken method keep returning "END_OBJECT" token in the end of parsing. You can reproduce this issue by following code:
ObjectMapper mapper = new ProtobufMapper();
String protobuf_str = "message Employee {\n"
+ " required string name = 1;\n"
+ " required int32 age = 2;\n"
+ " repeated string emails = 3;\n"
+ " optional Employee boss = 4;\n"
+ "}\n";
final ProtobufSchema schema = ProtobufSchemaLoader.std.parse(protobuf_str);
Employee empl = new Employee();
empl.age = 30;
empl.emails = new String[]{"foo@gmail.com"};
empl.name = "foo";
byte[] protobufData = mapper.writer(schema)
.writeValueAsBytes(empl);
JsonParser jsonParser = new ProtobufFactory().createParser(new ByteArrayInputStream(protobufData));
jsonParser.setSchema(schema);
JsonToken token;
while ((token = jsonParser.nextToken()) != null) {
System.out.println(token.id());
}
output:
1
5
6
5
7
5
3
6
4
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...endless