Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google protocol buffers vs json vs XML [closed]

I would like to know the merits & de-merits of

  • Google Protocol Buffers
  • JSON
  • XML

I want to implement one common framework for two application, one in Perl and second in Java. So, would like to create common service which can be used by both technology i.e. Perl & Java.

Both are web-applications.

Please share me your valuable thoughts & suggestion on this. I have seen many links on google but all have mixed opinions.

like image 859
Manoj Kathiriya Avatar asked Dec 25 '12 06:12

Manoj Kathiriya


People also ask

Should I use Protobuf or JSON?

Protobuf is mostly useful for internal services whereas JSON is mostly useful for web applications. Prior knowledge of schema is essential in decoding Protobuf messages, whereas data can be easily decoded or parsed in JSON with knowing schemas in advance.

Are protocol buffers faster than JSON?

It is essential to be aware that protobuf is not necessarily the fastest option. If your data is mainly string, then JSON format might be a good choice.

Does Protobuf support JSON?

Utility classes to convert protobuf messages to/from JSON format. The JSON format follows Proto3 JSON specification and only proto3 features are supported.

Is Protobuf lighter than JSON?

Protobuf messages were 9% smaller than JSON messages and they took only 4% less time to be available to the JavaScript code.


1 Answers

Json

  • human readable/editable
  • can be parsed without knowing schema in advance
  • excellent browser support
  • less verbose than XML

XML

  • human readable/editable
  • can be parsed without knowing schema in advance
  • standard for SOAP etc
  • good tooling support (xsd, xslt, sax, dom, etc)
  • pretty verbose

Protobuf

  • very dense data (small output)
  • hard to robustly decode without knowing the schema (data format is internally ambiguous, and needs schema to clarify)
  • very fast processing
  • not intended for human eyes (dense binary)

All have good support on most platforms.

Personally, I rarely use XML these days. If the consumer is a browser or a public API I tend to use json. For internal APIs I tend to use protobuf for performance. Offering both on public API (either via headers, or separate endpoints) works well too.

like image 199
Marc Gravell Avatar answered Sep 28 '22 20:09

Marc Gravell