Hey all!
Just a quick mini tutorial/blurb about using JSON. In the first version of the Animation and Rigging Toolkit, I used cPickle, because I didn't know any better :) If you're unfamiliar with cPickle and JSON, they are both Python modules (in this case) that allow you to write out Python data, like lists or dictionaries, and have them be read back in as that data type, instead of the usual string you'd get back from file.readlines().
There are a few reasons to switch to json over cPickle. First, as I learned with the tools, cPickle and source control do not mix well. cPickle seems to be very dependent on its new line/line ending characters staying intact, and Perforce would corrupt this by changing the line endings in the file, unless you set your line endings setting in P4 to use something like 'unix' instead of 'universal line endings'. This is somewhat okay in a studio setting, it's an easy enough thing to control, but when tools are mass distributed, this can become a nightmare. The other downer of cPickle is that the file is not human readable. Depending on what you're trying to save out, this might be acceptable. I found for saving out poses or templates or animation data though, that being able to open, read, and edit the data inside the file would have been mighty useful!
So, onto JSON! The functions for both are very similar, and they do very similar things, but JSON seems to be more forgiving with not getting corrupted when using source control, and it's human readable, so at the very least, one could edit the file to fix any possible issues.
To use json to write out a list of data, first I created the list I wanted to save out, then: