Content-Type: RST JSON rocks my socks. It stands for JavaScript Object Notation, and is an awesome new way to haul information around when space is not an issue (read: similar to what XML does). However, XML and JSON are different beasts. To an inventive mind, JSON can be used to completely replace XML, but XML has a much more acceptable syntax for lists of stuff which have attributes attached to them. JSON is good for describing intricate data structures, such as an array containing some arrays and some dictionaries, and the dictionaries each contain values of other dictionaries, lists, and individual string, integer, or boolean values. And, while .. _JSON: http://www.json.org .. sourcecode :: xml XML false may be fun for some people to write, I prefer .. sourcecode :: json {"title":"JSON", "value":true} I'll explain exactly how this works, after you see this awesome example, executed in Python2.6 via the new json module! .. sourcecode :: python >>> data = { 'a':1 , 2:'b' , 'foo':'bar', 'baz':{ 'yay':[1,'this',2,'is',3,'json'] , 'is json awesome?':True}} >>> data {'a': 1, 2: 'b', 'foo': 'bar', 'baz': {'is json awesome?': True, 'yay': [1, 'this', 2, 'is', 3, 'json']}} >>> import json >>> json_data = json.dumps(data) >>> json_data '{"a": 1, "2": "b", "foo": "bar", "baz": {"is json awesome?": true, "yay": [1, "this", 2, "is", 3, "json"]}}' >>> pretty_json_data = json.dumps(data, indent=2) >>> print pretty_json_data { "a": 1, "2": "b", "foo": "bar", "baz": { "is json awesome?": true, "yay": [ 1, "this", 2, "is", 3, "json" ] } } >>> edited_json_data = json_data.upper().replace('TRUE', 'true') # more on this later >>> edited_data = json.loads(edited_json_data) >>> edited_data {u'A': 1, u'2': u'B', u'BAZ': {u'IS JSON AWESOME?': True, u'YAY': [1, u'THIS', 2, u'IS', 3, u'JSON']}, u'FOO': u'BAR'} JSON is exactly what it sounds like: JavaScript Object Notation. I could take the string contents of json_data and stick them into a "var x = " statement in Javascript and it would immediately work. Implementations of JSON are present in "C, C++, C#, Java, JavaScript, Perl, Python, and many others", so there's no question of the portability of this beauty. Now, caveats? I've found two: - See where it turned the 2 into "2"? Since this is JSON, not PYON, it can only use strings for keys. python-json seems to take care of that gracefully, though. - Javascript is case sensitive about its booleans. I had to do a .replace('TRUE','true') for my code to run. Basically, just the limitations of Javascript itself. But, that doesnt mean it's any (much) less awesome! Besides, Google is using it as the standard output for its geocoding service. How cool is that? ----------------------- Now, on to my second topic: Antigravity_. Yes, Python will allow you to levitate in the near future as one of its core features. Just "import antigravity" and you'll be flying. However, this feature doesn't seem to be included in the Ubuntu python2.5 or python2.6 packages. Instead, it is included in the python3.0 package! Try it: .. _Antigravity: http://xkcd.com/353/ .. sourcecode :: shell fsufitch@ubuntu:~$ sudo apt-get install python3.0 ... fsufitch@ubuntu:~$ python3.0 -c "import antigravity" Whee!!