Getting down and dirty with Ada and JSON

JSON is a pretty neat data-interchange format. It is lightweight and both easy to read and write. It is also ever so slowly becoming the de facto standard for web-applications, because it is extremely easy to use with Javascript. As a matter of fact, JSON is a subset of the object literal notation of JavaScript so it can be used in the language with no muss or fuss.

But how does JSON fare when coupled with Ada?

Pretty good actually. I ventured into the realm of JSON suspecting I would end up having to write my own parser/generator, but as luck would have it, one of my favorite Ada libraries, GNATColl, turned out to have support for JSON in its latest SVN checkout, and even better: It was pretty good!

I started mucking about with the GNATColl.JSON package, and after an initial failure to make it work (due to me not being able to read properly), I made it fly. And it flew well. It is both intuitive to use, and very clean to read. There’s really nothing bad to say about the JSON support in GNATColl, except for perhaps one little thing: It’s still very new, so new in fact that at the time of writing, there’s no entry for it in the GNATColl manual. This is not a huge issue, but it’s worth taking into consideration.

To really drive home the fact that I enjoyed working with the GNATCOLL.JSON package, I wrote a couple of articles and dropped some test code at my GitHub page:

In short: JSON and Ada programming is a good match, so before settling on using XML for your data-interchange needs, perhaps it’s worth taking a look at JSON? It is much nimbler and very easy to work with.

JSON Support in GNATcoll

Today I grabbed the latest GNATcoll developer SVN commit and with it came a very nice surprise – it appears that AdaCore is adding JSON support to this already wonderful library. Here are the new files in question:

Looks very nice! To my knowledge, the only other Ada JSON library available, is the jdaughter library by Tero Koskinen. I don’t know how the two implementations compare to each other, but it sure is nice to have more choices.