1

JSON

{
"hello": "world"
}

Protobuf

message HelloWorld {
required string name = 1;
}

Why do we say that protobuf uses binary format during network exchange and json don't, even though network always will transfer using binary data format?

pzk
  • 29

1 Answers1

11

This would be more clear if you were comparing two more similar pieces of data with non-text data components.

For example, the following JSON is ALL text:

{
    "NumberOfClients": 20
}

The 20 is two separate characters in JSON, but would be represented as an actual binary integer in Protobuf, which in this case would be a single byte: ‭00010100‬

Further, I am not sure you are properly understanding Protobuf as you are comparing apples and oranges in your question. You are comparing JSON Data to a Protobuf Schema