protocol-buffers

Eclipse plugin for working with protobuf

寵の児 提交于 2019-12-03 07:10:03
问题 Protocol Buffers (protobuf) are a way of encoding structured data in an efficient yet extensible format. There's plugin for Netbeans, but I cannot find one for Eclipse. Does it exist? If yes, please, share the link. Thanks. 回答1: I recommend using Google's "Protocol Buffers Development Tools". It is a plugin for Eclipse that features automagic regeneration and error checking with quick fixes, among other things. It's available here: https://github.com/google/protobuf-dt/blob/master/README.md .

What's the preferred way to encode a “nullable” field in protobuf 2?

心不动则不痛 提交于 2019-12-03 06:56:18
I am defining a ProtoBuf message where I want to have a "nullable" field -- i.e., I want to distinguish between the field having a value and not having a value. As a concrete example, let's say I have "x" and "y" fields to record the coordinates of some object. But in some cases, the coordinates are not known. The following definition will not work, because if x or y are unspecified, then they default to zero (which is a valid value): message MyObject { optional float x = 1; optional float y = 2; } One option would be to add a boolean field recording whether the corresponding field's value is

Google Protobuf ByteString vs. Byte[]

会有一股神秘感。 提交于 2019-12-03 06:42:08
问题 I am working with google protobuf in Java. I see that it is possible to serialize a protobuf message to String, byte[], ByteString, etc: (Source: https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/MessageLite) I don't know what a ByteString is. I got the following definition from the the protobuf API documentation (source: https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/ByteString): "Immutable sequence of bytes.

How does protocol buffer handle versioning?

烂漫一生 提交于 2019-12-03 06:32:45
问题 How does protocol buffers handle type versioning? For example, when I need to change a type definition over time? Like adding and removing fields. 回答1: Google designed protobuf to be pretty forgiving with versioning: unexpected data is either stored as "extensions" (making it round-trip safe), or silently dropped, depending on the implementation new fields are generally added as "optional", meaning that old data can be loaded successfully however: do not renumber fields - that would break

Date and time type for use with Protobuf

放肆的年华 提交于 2019-12-03 06:28:26
问题 I'm considering to use Protocol Buffers for data exchange between a Linux and a Windows based system. Whats the recommended format for sending date/time (timestamp) values? The field should be small when serialized. 回答1: Although you aren't saying which languages you are using or what kind of precision you need, I would suggest using Unix time encoded into a int64 . It is fairly easy to handle in most languages and platforms (see here for a Windows example), and Protobufs will use a varint

Parsing Protocol-Buffers without knowing the .proto

China☆狼群 提交于 2019-12-03 05:51:06
问题 I know that protocol-buffers are a serialized format that requires a message format in the .proto in order to read back properly. But I have a file that I do not know the proper message format for because it isn't published. What I am trying to do is to reverse engineer the data myself so i can reconstruct the messages. To do this I need to read the raw file out where I can pick up the field numbers, types and values. Is there a program that will do this (preferrably in python but C/C++ is

Protocol buffer and OO design

南笙酒味 提交于 2019-12-03 05:43:23
I'm using protocol buffer as a wire data-format in a client-server architecture. Domain objects (java beans) will go through following life-cycle. Used in client side business logic Converted to protobuf format Transmitted to the server Converted back to domain object Used in server side business logic "Protocol Buffers and O-O Design" section in ProtoBuf documentation recommends wrapping generated class inside proper domain model. I'd like to find-out the best appoach. For e.g. I have a simple proto definition. package customer; option java_package = "com.example"; option java_outer_classname

How to convert from Json to Protobuf?

心不动则不痛 提交于 2019-12-03 05:42:27
问题 I'm new to using protobuf, and was wondering if there is a simple way to convert a json stream/string to a protobuf stream/string in Java? For example, protoString = convertToProto(jsonString) I have a json string that I want to parse into a protobuf message. So, I want to first convert the json string to protobuf, and then call Message.parseFrom() on it. Thanks in advance for the help! 回答1: With proto3 you can do this using JsonFormat. It parses directly from the JSON representation, so

How do I generate a .proto file from a C# class decorated with attributes?

落爺英雄遲暮 提交于 2019-12-03 05:40:10
问题 Trying to get my mind around google protobuf. I found some implementation of protobuf in C# but they seems to lack one feature: the ability to generate .proto files automatically from an existing C# class decorated with attributes. The reason I want to do it this way instead of going from auto-generated C# classes from .proto file is because I already have the C# classes defined in my project and I don't want to duplicate them just to satisfy ProtoBuf. Does anyone have encountered such a

IDL for JSON REST/RPC interface

蓝咒 提交于 2019-12-03 05:39:17
We are designing a fairly complex REST API, in which most of the I/O are JSON encoded objects with a specific structure. One challenge we have found is to document the API in such a way that makes it easier for clients to post correct input and process output. Because the data of both the input and output requires fairly complex JSON objects, client developers often introduce bugs related to the structure of the I/O objects. With all of the JSON web API's these days, I would have hoped for a general solution, but I am having a hard time finding one. I looked into json-schema which is a json