Member-only story

What is protobuf and when to consider it over xml/json for web services communication ?

Aditya
3 min readApr 11, 2020

--

Before we dive into details lets brush up on a few basic concepts for this article.

What is a web service → Web service in simple terms expose resource for CRUD(create/read/update/delete) operations over network

What is serialization/ de-serialization → In object-oriented world( like python or java or c# or c++or ruby e.t.c), serialization is the process of translating data structures or object state into a format(xml/json/protobuf) that can be stored or transmitted. De-serialization is the process of constructing data structure/object state from the represented format (xml/json/protobuf)
To give an idea we can represent object state in an xml as described here https://www.edureka.co/blog/serialization-of-java-objects-to-xml-using-xmlencoder-decoder/

XML format

<medium>
<title>Protobuf article</name>
<status>DRAFT</status>
</medium>

Protobuf format

##.proto file
message Medium {
required string title = 1;
enum StatusType {
DRAFT = 0;
PUBLISHED = 1;
}

message Status {
required StatusType type = 0[default = DRAFT];
}
required Status status = 2;
}
# Textual representation of a protocol…

--

--

Aditya
Aditya

Written by Aditya

Principal data engineer → Distributed Threat hunting security platform | aws certified solutions architect | gssp-java | Chicago-IL

No responses yet

Write a response