2013-07-08 49 views
0

我想在協議緩衝區消息中添加字符串數組,這是我無法做到的。我已經寫了如下在協議緩衝區中添加字符串數組

repeated string data = 1[packed=true]; 

我得到了下面的錯誤:

[packed = true] can only be specified for repeated primitive fields. 

我可能能夠做到這一點與相同語法int數組。我很困惑爲什麼字符串被認爲是非原始類型。 任何人都可以幫助我。 謝謝!

回答

0

請參閱Protobuf Documentation的「指定字段規則」一節。本質上,僅包裝對數字字段有意義。

保留繁榮報價:

For historical reasons, repeated fields of basic numeric types aren't encoded as efficiently as they could be. New code should use the special option [packed=true] to get a more efficient encoding.

+0

感謝您的答覆。所以我們不能爲字符串類型做它。 – Srikanth

+2

只要刪除'[packed = true]'。另外,請閱讀錯誤消息之間的文檔,並認爲這不應該成爲問題。 –