diff options
author | Rune Halvorsen <runefh@gmail.com> | 2009-07-05 00:05:51 +0200 |
---|---|---|
committer | Rune Halvorsen <runefh@gmail.com> | 2009-07-05 00:05:51 +0200 |
commit | 75ebe7f04a91890c541fb8a2a11c03d407b56d66 (patch) | |
tree | 6bc07cbf65ed009ff01b4823c9f60bcf373ced59 /README | |
parent | 3225fbc73ab48e8dc370fd016bf1834f01d7d22c (diff) | |
download | anyjson-75ebe7f04a91890c541fb8a2a11c03d407b56d66.tar.gz |
renamed README
Diffstat (limited to 'README')
-rw-r--r-- | README | 59 |
1 files changed, 59 insertions, 0 deletions
@@ -0,0 +1,59 @@ +############################## +anyjson - JSON library wrapper +############################## + +Overview +-------- + +Anyjson loads whichever is the fastest JSON module installed and provides +a uniform API regardless of which JSON implementation is used. + +Originally part of carrot (http://github.com/ask/carrot/) + +Examples +-------- + +To serialize a python object to a JSON string, call the `serialize` function: + +>>> import anyjson +>>> anyjson.serialize(["test", 1, {"foo": 3.141592}, "bar"]) +'["test", 1, {"foo": 3.141592}, "bar"]' + +Conversion the other way is done with the `deserialize` call. + +>>> anyjson.deserialize("""["test", 1, {"foo": 3.141592}, "bar"]""") +['test', 1, {'foo': 3.1415920000000002}, 'bar'] + +Regardless of the JSON implementation used, the exceptions will be the same. +This means that trying to serialize something not compatible with JSON +raises a TypeError: + +>>> anyjson.serialize([object()]) +Traceback (most recent call last): + <snipped traceback> +TypeError: object is not JSON encodable + +And deserializing a JSON string with invalid JSON raises a ValueError: + +>>> anyjson.deserialize("""['missing square brace!""") +Traceback (most recent call last): + <snipped traceback> +ValueError: cannot parse JSON description + + +Contact +------- + +The module is maintaned by Rune F. Halvorsen <runefh@gmail.com>. +The project resides at http://bitbucket.org/runeh/anyjson . Bugs and feature +requests can be submitted there. Patches are also very welcome. + +Changelog +--------- + +See CHANGELOG file + +License +------- + +see the LICENSE file |