Swaroop C H

blog books about contact subscribe

Wrote an EDN format reader and writer in Python

24 Dec 2012

I was reading about the EDN format over the weekend. EDN (pronounced like in "eden garden") is a data format in the same league as JSON but is supposed to have some nifty features such as sets, keywords, date-time type, custom types, and also being a proper subset of Clojure.

Having a date-time type as well as custom types seems useful to me, so I was taking a look at the current Python implementations of the EDN format and I didn't find them satisfactory, for example, one of the listed ones had all custom parsing code which was difficult to read, one was not even a real implementation, just boilerplate code, etc.

So I thought why not create a better implementation and I did - it is up on GitHub at https://github.com/swaroopch/edn_format.

It has been a long time since I did lex and yacc, so it was a fun weekend project :)

Comments

ekameleon says:

Since 2003-2004 you can use the "eden" format (ECMAScript Data Exchange Notation) to serialize or deserialize your objects : http://code.google.com/p/edenrr/wiki/edenFeatures

eden is a serializer/deserializer library using a subset of the ECMAScript notation, it allows to exchange and interpret data keeping the structure and the type.

The choice to define the "edn_format" is not a big mistake ?

Swaroop says:

@ekameleon I have not previously heard about the "eden" that you mentioned - but it doesn't seem to be a data format, more like a subset of JavaScript - I mean, it can do function calls! Comparatively, this EDN format seems to be simpler to me.

Nevertheless, people create formats, protocols, and technologies to solve their need, and from that perspective, EDN is a good thing, not a mistake :)

Feedback

There's no comment box, but please do email me or tweet me your thoughts and criticisms, and I will publish the relevant ones here.