protobuf中c++生成的string可以在java中来parse吗

C++语言 码拜 7年前 (2017-04-24) 2008次浏览
如题
本人是在android中用jni回调,jni中收到的string是用c++的SerializeAsString()输出的,
在jni中本人将string转为byte[]数组,回调到java中,通过javaparseFrom来解析。
现在在java端报的错误是
com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.
但是同样的string,本人在jni中用c++的ParseFromString是可以解析成功的。
proto是同一个文件,分别生成了c++和java两个版本。
用过protobuf的各路高手,问一下这是什么问题?谢谢了
解决方案

10

解决了就行,

20

怎么解决的?

10

帮结帖+蹭分

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明protobuf中c++生成的string可以在java中来parse吗
喜欢 (0)
[1034331897@qq.com]
分享 (0)