Skip to main content

Python package that handles loading and dumping json files in a compressed fashion.

Project description

Travis CI build SonarCloud Quality SonarCloud Maintainability Codacy Maintainability Maintainability Pypi project Pypi total project downloads

Python package that handles loading and dumping json files in a compressed fashion. The library is loosely based on the compress_pickle library.

How do I install this package?

As usual, just download it using pip:

pip install compress_json

Tests Coverage

Since some software handling coverages sometime get slightly different results, here’s three of them:

Coveralls Coverage SonarCloud Coverage Code Climate Coverate

Available compression modes

The compression modes, detected automatically by the file name, are gzip, bz2 and lzma, with the notable exception of zip which seems difficult to integrate in the json pipeline.

Usage example

The library is extremely easy to use:

import compress_json

D = {
    "A":{
        "B":"C"
    }
}
compress_json.dump(D, "filepath.json.gz") # for a gzip file
compress_json.dump(D, "filepath.json.bz") # for a bz2 file
compress_json.dump(D, "filepath.json.lzma") # for a lzma file

D1 = compress_json.load("filepath.json.gz") # for loading a gzip file
D2 = compress_json.load("filepath.json.bz") # for loading a bz2 file
D3 = compress_json.load("filepath.json.lzma") # for loading a lzma file

Advanced usage

Clearly you can pass parameters to either the chosen compression mode or the json library as follows:

import compress_json

D = {
    "A":{
        "B":"C"
    }
}
compress_json.dump(
    D, "filepath.json.gz",
    compression_kwargs = {kwargs go here},
    json_kwargs = {kwargs go here}
)

D4 = compress_json.load(
    "filepath.json.gz",
    compression_kwargs = {kwargs go here},
    json_kwargs = {kwargs go here}
)

Project details


Release history Release notifications

Download files

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

Files for compress-json, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size compress_json-1.0.0.tar.gz (4.1 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 DigiCert DigiCert EV certificate StatusPage StatusPage Status page