I been trying to encode strings using protoc cli utility. Noticed that output still contains plain text. What am i doing wrong?
osboxes@osboxes:~/proto/bin$ cat ./teststring.proto
syntax = "proto2";
message Test2 {
optional string b = 2;
}
echo b:\"my_testing_string\"|./protoc --encode Test2 teststring.proto>result.out
result.out contains:
^R^Qmy_testing_string
protoc versions libprotoc 3.6.0 and libprotoc 2.5.0
{"b":2}
- that's 7 bytes, and probably much more if you have real names (not justb
). In protobuf that would usually be 2 bytes: 1 byte for the field header and data type tag, one byte for the value encoded as "varint". Additionally, JSON decoder has lots of text parsing to do - much more intensive than a dense binary protocol. – Petrology