- JSON is more compact, meaning smaller file sizes to send to a client
- JSON is formal and precise, so there's less possibility of ambiguity or exceptions
- JSON is much faster to parse than XML, and you don't need to write any custom code to parse it
-
Current code to parse a book (already broken with new COLLXML format, and code complexity increases exponentially with more features):
parseHTML = (html) -> if typeof html isnt 'string' then return [] results = [] $(html).find('> ol').find('> li').each (index, el) -> $el = $(el) $node = $el.children().eq(0) if $node.is('a') id = $node.attr('href') title = $node.text() # Only remember the title if it's overridden if not title or $node.hasClass('autogenerated-text') results.push({id: id}) else results.push({id: id, title: title}) return results
-
No code is required to parse JSON, since support is built-in to Backbone, but if you needed to, it would always be one line:
JSON.parse(string)
in JavaScript- In Python, just
import json
and thenjson.loads(string)
-
- JSON, unlike XML, matches the data model of most programming languages
- Literally "JavaScript Object Notation", it can be serialized and parsed back into an object in any modern browser
- Maps easily to Python as well: Object = Dictionary, Array = List, etc.
- Support for JSON has only been growing as it is becoming the default data exchange format for the web
- PostgreSQL has built-in support for JSON, including automatic validation
- Backbone.js is designed to work with specifically with JSON
- "Backbone.js gives structure to web applications ... and connects it all to your existing API over a RESTful JSON interface."
- An XML or HTML markup of a book can be generated from data more easily and quickly than XML can be parsed into data
- A template (or multiple templates) could be used to easily convert data into any format, simplifying support for different formats. So, for example, we should be able to avoid restyling every book.
- Because of things like xincludes, XML must be parsed into data, manipulated, and then re-generated. Storing as JSON skips the first step, because it already is data.
- We're already using JSON. Currently, the XML/HTML is simply being served as a JSON field. Serving just JSON would simplify it to a single data format.
- Folders are already serving their contents as JSON.
- ATC is effectively just taking the HTML/XML being served currently and converting it into a JavaScript Object (JSON).
dak/json
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Why JSON
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published