Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A convenient library to deal with large json data

Project description

Activejson

PyPI version CircleCI

A convenient library to deal with large json data

A convenient library to deal with large json data. The purpose of this package is help to deal with complex json-like data, converting them into a more manageable data structure.

Installation

OS X & Linux:

From PYPI

$ pip3 install activejson

from the source

$ git clone https://github.com/dany2691/activejson.git
$ cd activejson
$ python3 setup.py install

Usage example

You can flat a complex dict the next way:

complex_json = {'cat': {'grass': 'feline', 'mud': 'you never know',
                        'horse': 'my joke'},
                'dolphin': [{'tiger': [{'bird': 'blue jay'},
                                      {'fish': 'dolphin'}]},
                            {'cat2': 'feline'}, {'dog2': 'canine'}],
                'dog': 'canine'}
from activejson import flatten_json

flatten_complex_json = flatten_json(complex_json)

print(flatten_complex_json)

The result could be the next:

{'cat_grass': 'feline',
 'cat_horse': 'my joke',
 'cat_mud': 'you never know',
 'dog': 'canine',
 'dolphin_0_tiger_0_bird': 'blue jay',
 'dolphin_0_tiger_1_fish': 'dolphin',
 'dolphin_1_cat2': 'feline',
 'dolphin_2_dog2': 'canine'}

On the other hand, is possible to convert that dict into an object with dynamic attributes:

from activejson import FrozenJSON

frozen_complex_json = FrozenJSON(complex_json)

print(frozen_complex_json.cat.grass)
print(frozen_complex_json.cat.mud)
print(frozen_b.dolphin[2].dog2)

The result could be the next:

'feline'
'you never know'
'canine'

To retrieve the underlying json, is possible to use the json property:

frozen_complex_json.json
{'cat_grass': 'feline',
 'cat_horse': 'my joke',
 'cat_mud': 'you never know',
 'dog': 'canine',
 'dolphin_0_tiger_0_bird': 'blue jay',
 'dolphin_0_tiger_1_fish': 'dolphin',
 'dolphin_1_cat2': 'feline',
 'dolphin_2_dog2': 'canine'}

Development setup

This project uses pipenv for dependecy resolution. It's a kind of mix between pip and virtualenv. Follow the next instructions to setup the development enviroment.

$ git clone https://github.com/dany2691/activejson.git
$ cd activejson
$ pipenv shell
$ pipenv install -e .

To run the test-suite, inside the pybundler directory:

$ pytest test/ -vv

Meta

Daniel Omar Vergara Pérez – @dan1_netdaniel.omar.vergara@gmail.com

https://github.com/dany2691

Contributing

  1. Fork it (https://github.com/dany2691/activejson)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for activejson, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size activejson-0.3.0-py3-none-any.whl (4.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size activejson-0.3.0.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page