Tuesday, November 6, 2018

JSON and Protobuf

JSON : Java Script Object Notation (but not a strict subset of javascript, can be used by python, java, javascript etc)

Messages sent as object, instead of plain text string, so it's easier to read by the consumer (without the need for parsing).

Convert object from java to JSON on the producer side, and convert from JSON to java object on the consumer side.

For using JSON with C++, you can use Boost's property tree. Boost Property tree can be used to represent XML, JSON, INI files, file paths etc.

read_json, write_json are the two basic methods.
For more info - http://zenol.fr/blog/boost-property-tree/en.html


Protobuf : Protocol buffer (by google)
Messages and services are defined in file.proto, compiled using 'protoc'
Supports - mandatory(required) and optional fields, tagging (to provide bandwidth/storage savings), composition, repeated (container).

No comments:

Post a Comment