• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

anyjson/H21-Jun-2012-143100

anyjson.egg-info/H03-May-2022-8665

tests/H03-May-2022-202161

CHANGELOGH A D21-Jun-20121.6 KiB6743

LICENSEH A D21-Jun-20121.5 KiB3024

MANIFEST.inH A D21-Jun-201260 44

PKG-INFOH A D21-Jun-20123 KiB8665

READMEH A D21-Jun-20121.5 KiB6040

setup.cfgH A D21-Jun-201259 64

setup.pyH A D21-Jun-20122.9 KiB10186

README

1##############################
2anyjson - JSON library wrapper
3##############################
4
5Overview
6--------
7
8Anyjson loads whichever is the fastest JSON module installed and provides
9a uniform API regardless of which JSON implementation is used.
10
11Originally part of carrot (http://github.com/ask/carrot/)
12
13Examples
14--------
15
16To serialize a python object to a JSON string, call the `serialize` function:
17
18>>> import anyjson
19>>> anyjson.serialize(["test", 1, {"foo": 3.141592}, "bar"])
20'["test", 1, {"foo": 3.141592}, "bar"]'
21
22Conversion the other way is done with the `deserialize` call.
23
24>>> anyjson.deserialize("""["test", 1, {"foo": 3.141592}, "bar"]""")
25['test', 1, {'foo': 3.1415920000000002}, 'bar']
26
27Regardless of the JSON implementation used, the exceptions will be the same.
28This means that trying to serialize something not compatible with JSON
29raises a TypeError:
30
31>>> anyjson.serialize([object()])
32Traceback (most recent call last):
33  <snipped traceback>
34TypeError: object is not JSON encodable
35
36And deserializing a JSON string with invalid JSON raises a ValueError:
37
38>>> anyjson.deserialize("""['missing square brace!""")
39Traceback (most recent call last):
40  <snipped traceback>
41ValueError: cannot parse JSON description
42
43
44Contact
45-------
46
47The module is maintaned by Rune F. Halvorsen <runefh@gmail.com>.
48The project resides at http://bitbucket.org/runeh/anyjson . Bugs and feature
49requests can be submitted there. Patches are also very welcome.
50
51Changelog
52---------
53
54See CHANGELOG file
55
56License
57-------
58
59see the LICENSE file
60