OData, jQuery and datajs

Over the last couple of days, I’ve received a number of inquiries about the relationship between JSON, OData, jQuery and datajs and how to choose between them.

These aren’t all the same kinds of things, so I’ll take them one by one.

Talking the talk

JSON is a format to represent data, much like XML. It’s the rules for reading and writing text and figuring out what pieces of data have what name and how they relate. JSON, however, doesn’t tell you what this data means, or what you can do with it.

OData, on the other hand, is a protocol that uses JSON as well as ATOM and XML. If you’re talking to an OData service and get a JSON response back, you know which pieces of information are property values, which are identifiers, which are used for concurrency control, etc. It also describes how you can interact with the service using the supported formats to do things with the data: create it, update it, delete, link it, etc.

So far, we’ve only been talking about specifications or agreements as to how things work, but we haven’t discussed any actual implementations. jQuery and datajs are two specific JavaScript libraries that actually get things done.

Walking the walk

Now we get to the final question: how do you compare and choose between jQuery and datajs? The answer is actually quite simple, because they do different things, so you use one or the other or both, depending on what you’re trying to do.

jQuery is great at removing differences between browser APIs, manipulating the page structure, doing animations, supporting richer controls, and simplifying network access (I’m not part of the jQuery development team, so my apologies if I’m mischaracterising something). It includes AJAX support that allows you to send text, JSON, HTML and form-style fields over the web.

datajs is focused on handling data (unsurprisingly). The first release will deliver great OData support, including both ATOM and JSON formats, the ability to parse or statically declare metadata and apply it to improve the results, the ability to read and write batches of request/responses, smoothing format and versioning differences, and whatever else is needed to be first-class OData citizen. We don’t foresee getting into the business of writing a DOM query library or a control framework – there are many other libraries that are really good at this and we’d rather focus on enabling new functionality.

Hope this clarifies things, but if not, just drop a message and I’ll be happy to discuss.


Comments (0)

Skip to main content