An attempt to recreate the way json behaves in Javascript, but in Python
Project description
Classy-JSON
dict.key
(Dot access) for Python dictionaries
How do I use Classy-JSON?
- All functions from the built in json module are supported! json module docs
- The only difference is that you can now access dictionaries via
dict.key
as well asdict['key']
- Note: using
dict.key
is about 2-2.5x slower [in some cases] than usingdict['key']
, however, usingdict['key']
is just as fast as in normal Python dictionaries. For most use cases, this difference is negligible. - What seperates Classy-JSON and its custom data structures from other alternatives? Classy-JSON is both better in its speed and package size, other similiar packages have unecessary code and just aren't as fast as Classy-JSON
Example Usage
import classyjson as cj
# load data from a json file
with open('tests/test_large.json', 'r') as f:
data = cj.load(f)
# turn a regular dictionary into a ClassyDict
my_dict = {'a': 'b'}
my_classy_dict = cj.classify(my_dict)
# or
my_classy_dict = cj.ClassyDict(my_dict)
# make a new ClassyDict
new_classy_dict = cj.ClassyDict()
Setup / Install
Using pip:
python3 -m pip install classy-json
Manually:
- Clone the repository
git clone https://github.com/Iapetus-11/Classy-JSON.git
- cd into the directory
cd Classy-JSON
- Run setup.py
python3 setup.py build install
Contribution
- Fork the repository
- Make any changes
- Submit a pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
classy-json-3.0.0.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for classy_json-3.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d35b89a53c5077497a993860fc3b4cd85e55d1f56f8968cdc72eb29297ec481 |
|
MD5 | 55689746dcb89b456065d1b56b206ae1 |
|
BLAKE2b-256 | 80ae1bbd28de510917618980348b7b02079c0de3e73ad7d1ed66ff9662abd0a2 |