Spreading the XML paradigm around
2019-02-12
Yes, I'm XML-head but I can admit that there are valid use-cases for JSON. For example sending few bits of information from backend to browsers in AJAX applications. It's a pity that leading IT company can not do the same for XML when JSON is clearly not right tool to do the job.
Google recently announced REST API for Google documents. This opens plenty of new integration opportunities for Google Docs. But at the same time it shows that Google has lost his sanity when designing this API. If you are designing API for working with documents it should be easy to work with documents – you usually need to convert them to other formats, scrape data from them or fill them using templates. This is nothing new and in past two decades HTML or XML based formats has been used for this. This is no surprise as XML (and its predecessor SGML) has been designed for storing documents.
Lets assume that we want to represent the following document with one paragraph:
Hello World
In XML/HTML we can do this very easily as:
<p><b>Hello</b> <i>World</i></p>
Well Google engineers probably don't get only free coffee and lunches but probably also some strong weed. In Google Docs API such paragraph will be represented as:
{ "content": [ { "endIndex": 12, "paragraph": { "elements": [ { "endIndex": 6, "startIndex": 1, "textRun": { "content": "Hello", "textStyle": { "bold": true } } }, { "endIndex": 7, "startIndex": 6, "textRun": { "content": " ", "textStyle": {} } }, { "endIndex": 12, "startIndex": 7, "textRun": { "content": "World", "textStyle": { "italic": true } } } ] } } ] }
I don't think I can add anything sensible after this.