Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/catalyst/anyjson
A download of https://pypi.org/project/anyjson/ with changes to support Python 3 only
https://github.com/catalyst/anyjson
Last synced: 3 days ago
JSON representation
A download of https://pypi.org/project/anyjson/ with changes to support Python 3 only
- Host: GitHub
- URL: https://github.com/catalyst/anyjson
- Owner: catalyst
- License: other
- Created: 2021-09-16T22:17:39.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-27T17:23:34.000Z (over 2 years ago)
- Last Synced: 2023-04-18T23:29:49.373Z (over 1 year ago)
- Language: Python
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
##############################
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):
TypeError: object is not JSON encodableAnd deserializing a JSON string with invalid JSON raises a ValueError:
>>> anyjson.deserialize("""['missing square brace!""")
Traceback (most recent call last):
ValueError: cannot parse JSON description#### Contact
The module is maintaned by Rune F. Halvorsen .
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](CHANGELOG)
#### License
See [LICENSE](LICENSE)