我正在将我的protobuf消息保存到文件中,并且格式都是乱码。我已经看到它在protobug消息将以与.proto文件相同的格式保存到磁盘之前完成。我这样做:Proto缓冲区没有以可读格式存储数据
using (Stream output = File.OpenWrite(@"logs\listings.txt"))
{
listingBook.AddClisting(_listing);
listingBook.Build().WriteTo(output);
}
但我得到的是一个似乎与奇怪的标签分隔开的错位文件。我希望它看起来当它被保存到磁盘一样是喜欢例子:
# Textual representation of a protocol buffer.
# This is *not* the binary format used on the wire.
person {
name: "John Doe"
email: "[email protected]"
}
如果您想要JSON,请使用JSON序列化程序... Proto缓冲区并不意味着人类可读。 –