As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

9

And you think there's likely to be a concensus here?
– BarmarDec 25 '12 at 7:16

Thanks lot. But would like to know more Protocol Buffers vs JSON.
– Manoj KathiriyaDec 25 '12 at 7:24

16

@Barmar It' not about consensus, it's about rational choice, about pros and cons, it's good that the question was asked before the meta police started to lower the quality of SO content.
– Boris TreukhovNov 18 '14 at 6:40

I used to object strongly to such questions being closed arbitrarily. But the fact is, if I were consulting to a project that needed to make this choice, I would want a lot more information than typically appears in an SO post; any advice you will get here is anecdotal and based on almost complete ignorance of the requirements and constraints of your particular project.
– Michael KayDec 30 '16 at 23:23

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.

XML is more work to decode, but validation can be a major advantage over JSON. Validating your XML with a schema before you process a payment transaction it contains gives you an extra layer of robustness.
– CC.Jul 11 '13 at 17:37

8

XML also allows a narrative style where text is alternated with tags inclusions like <value>This is a <attention>narrative style</attention>. Tags could appear <exclamation /> in the middle of text</value>. This is the unique feature of XML when compared with JSON and Protocol Buffers.
– PaulJun 16 '14 at 12:33

3

@Marc Gravell: How about in terms of forward-compatibility. It's my impression that this is one of protobuf's big selling points?
– Thomas AhleJul 6 '14 at 16:47

1

Igor Ganapolsky it is my understanding that this is pretty much conceptually impossible, as there is very little to no parsing necessary for protobuffs, while the processing phase is long and inevitable with json.
– Jules G.M.Sep 12 '15 at 4:57

3

Just to mention that you can use schemas with JSON too.
– Jesus AnguloMay 25 '17 at 20:00