jsonvice


Namejsonvice JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/deftio/jsonvice
Summaryjsonvice minifies JSON files by trimming floating point precision.
upload_time2024-09-11 03:48:57
maintainerNone
docs_urlNone
authorManu Chatterjee
requires_python<4.0,>=3.8
licenseNone
keywords json minify truncate floating point precision json quanitize quantize
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/jsonvice.svg)](https://badge.fury.io/py/jsonvice)
[![Build Status](https://api.travis-ci.com/deftio/jsonvice.svg?branch=master)](https://app.travis-ci.com/deftio/jsonvice)
[![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)

# About jsonvice  

jsonvice is command line tool for minifying JSON with optimal precision truncation/rounding.  In many applications floating point values in JSON can be very long (15 digits or more) but this level of accuracy isn't needed and takes up much space.

jsonvice allows the truncation of all the embedded floating point numbers (wherever they appear) to a specified number of digits. 

It also removes unnecessary white space to minify JSON files.

sample_input.json

```json
{
    "x" :   12.32,
    "y": 0.23482498323433,
    "z": "simple test",
    "a" : [ 1, 2, 3.23423434343 ]
}
```

now run jsonvice

```sh
jsonvice -i input.json -o output.json -p 4
```

ouput.json

```json
{"x":12.32,"y":0.2348,"z":"simple test","a":[1,2,3.2342]}
```


# More Examples

compactify json and reduce floating point precision to max of 5 digits by rounding
sh

```shell
jsonvice -i sample_input.json -o output.json -p 5
```

compactify json and reduce floating point precision to max of 5 digits by rounding down

```sh
jsonvice -i myfile.json -o output.json -p 5 -q floor
```

jsonvice also allows stdin / stdout pipes to be used

```sh
cat simple_test.json | python3 path/to/jsonvice.py -i - -o - > output_test.json
```

jsonvice can also beautify (pretty print) json, while still performing precision truncation.  Note this makes the file larger.

```sh
jsonvice -i myfile.json -o output.json -p 3 -b
```

# Building and Source

All source is at [jsonvice](https://github.com/deftio/jsonvice)

jsonvice is built with Python using the Poetry packaging and build tool.

pip3 install poetry  # if not installed.

poetry update
poetry install
poetry build

poetry run jsonvice ...parameters...

Example

```sh
poetry run jsonvice -i inputfile.json -o outputfile.json -p 4
```



# Installing as stand alone commandline tool

pip can be used into install jsonvice as stand alone tool (note python 3.6 should or later specified)
```sh
pip install jsonvice
```

### pipx install

pipx can be used to install a stand alone version of jsonvice as a command line tool. Note pipx is like pip or pip3 but installs programs with their own virtual environment.

```sh
pipx install jsonvice
```

or install from github repo 

```sh
pipx install git+https://github.com/deftio/jsonvice
```

Now you can use jsonvice at the commandline without typing python3 like this example:

```sh
jsonvice -i inputfile.json -o - -b
```

## Python version support

Python version 3.6 or higher is required to build jsonvice.  If pipx is used for install isolation takes place automatically.

# Testing

Both pytest and tox were used to build jsonvice.  Testing can be performed at the command line via either tool:

```sh
poetry run pytest
```
or
```sh
tox
```

# History & Motivation

json vice started as a script to compactify / minify some large machine learning model files which had large floating point numbers.   By rounding to fixed number of sig digits and then testing the models against testsuites to see the effects of truncation.

At the time couldn't find a tool and whipped up small script (the original script is in /dev directory).

So jsonvice was built to learn / test practices around the python poetry and pipx tools, for use in other projects, but starting with a small example cli program that already worked.  

# License

jsonvice uses the BSD-2 open source license

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/deftio/jsonvice",
    "name": "jsonvice",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "json, minify, truncate floating point precision, json quanitize, quantize",
    "author": "Manu Chatterjee",
    "author_email": "deftio@deftio.com",
    "download_url": "https://files.pythonhosted.org/packages/c2/4b/62d5bc1a46a0d446211b23203d05d8ebfd0653504105b0430a64aa9abad8/jsonvice-1.0.2.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://badge.fury.io/py/jsonvice.svg)](https://badge.fury.io/py/jsonvice)\n[![Build Status](https://api.travis-ci.com/deftio/jsonvice.svg?branch=master)](https://app.travis-ci.com/deftio/jsonvice)\n[![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)\n\n# About jsonvice  \n\njsonvice is command line tool for minifying JSON with optimal precision truncation/rounding.  In many applications floating point values in JSON can be very long (15 digits or more) but this level of accuracy isn't needed and takes up much space.\n\njsonvice allows the truncation of all the embedded floating point numbers (wherever they appear) to a specified number of digits. \n\nIt also removes unnecessary white space to minify JSON files.\n\nsample_input.json\n\n```json\n{\n    \"x\" :   12.32,\n    \"y\": 0.23482498323433,\n    \"z\": \"simple test\",\n    \"a\" : [ 1, 2, 3.23423434343 ]\n}\n```\n\nnow run jsonvice\n\n```sh\njsonvice -i input.json -o output.json -p 4\n```\n\nouput.json\n\n```json\n{\"x\":12.32,\"y\":0.2348,\"z\":\"simple test\",\"a\":[1,2,3.2342]}\n```\n\n\n# More Examples\n\ncompactify json and reduce floating point precision to max of 5 digits by rounding\nsh\n\n```shell\njsonvice -i sample_input.json -o output.json -p 5\n```\n\ncompactify json and reduce floating point precision to max of 5 digits by rounding down\n\n```sh\njsonvice -i myfile.json -o output.json -p 5 -q floor\n```\n\njsonvice also allows stdin / stdout pipes to be used\n\n```sh\ncat simple_test.json | python3 path/to/jsonvice.py -i - -o - > output_test.json\n```\n\njsonvice can also beautify (pretty print) json, while still performing precision truncation.  Note this makes the file larger.\n\n```sh\njsonvice -i myfile.json -o output.json -p 3 -b\n```\n\n# Building and Source\n\nAll source is at [jsonvice](https://github.com/deftio/jsonvice)\n\njsonvice is built with Python using the Poetry packaging and build tool.\n\npip3 install poetry  # if not installed.\n\npoetry update\npoetry install\npoetry build\n\npoetry run jsonvice ...parameters...\n\nExample\n\n```sh\npoetry run jsonvice -i inputfile.json -o outputfile.json -p 4\n```\n\n\n\n# Installing as stand alone commandline tool\n\npip can be used into install jsonvice as stand alone tool (note python 3.6 should or later specified)\n```sh\npip install jsonvice\n```\n\n### pipx install\n\npipx can be used to install a stand alone version of jsonvice as a command line tool. Note pipx is like pip or pip3 but installs programs with their own virtual environment.\n\n```sh\npipx install jsonvice\n```\n\nor install from github repo \n\n```sh\npipx install git+https://github.com/deftio/jsonvice\n```\n\nNow you can use jsonvice at the commandline without typing python3 like this example:\n\n```sh\njsonvice -i inputfile.json -o - -b\n```\n\n## Python version support\n\nPython version 3.6 or higher is required to build jsonvice.  If pipx is used for install isolation takes place automatically.\n\n# Testing\n\nBoth pytest and tox were used to build jsonvice.  Testing can be performed at the command line via either tool:\n\n```sh\npoetry run pytest\n```\nor\n```sh\ntox\n```\n\n# History & Motivation\n\njson vice started as a script to compactify / minify some large machine learning model files which had large floating point numbers.   By rounding to fixed number of sig digits and then testing the models against testsuites to see the effects of truncation.\n\nAt the time couldn't find a tool and whipped up small script (the original script is in /dev directory).\n\nSo jsonvice was built to learn / test practices around the python poetry and pipx tools, for use in other projects, but starting with a small example cli program that already worked.  \n\n# License\n\njsonvice uses the BSD-2 open source license\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "jsonvice minifies JSON files by trimming floating point precision.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/deftio/jsonvice",
        "Repository": "https://github.com/deftio/jsonvice"
    },
    "split_keywords": [
        "json",
        " minify",
        " truncate floating point precision",
        " json quanitize",
        " quantize"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "943278e40b111291157a9c68fa0686fea7ca0fd952bdfe860c7c2b7756f40a6e",
                "md5": "34c0644a37050a3417e3f91dec3174e0",
                "sha256": "ac129a6d645fbf1ca734fd5589a13b6b9e87746a37728813fc0937f328d574da"
            },
            "downloads": -1,
            "filename": "jsonvice-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "34c0644a37050a3417e3f91dec3174e0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 5999,
            "upload_time": "2024-09-11T03:48:56",
            "upload_time_iso_8601": "2024-09-11T03:48:56.102986Z",
            "url": "https://files.pythonhosted.org/packages/94/32/78e40b111291157a9c68fa0686fea7ca0fd952bdfe860c7c2b7756f40a6e/jsonvice-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c24b62d5bc1a46a0d446211b23203d05d8ebfd0653504105b0430a64aa9abad8",
                "md5": "ac4f2bb15baaf4dd18161b2a2d56805d",
                "sha256": "2e11cb98eba02919109b5c1ebdc566026f40ccb84719262442d85b3ba06a46ac"
            },
            "downloads": -1,
            "filename": "jsonvice-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ac4f2bb15baaf4dd18161b2a2d56805d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 5323,
            "upload_time": "2024-09-11T03:48:57",
            "upload_time_iso_8601": "2024-09-11T03:48:57.363751Z",
            "url": "https://files.pythonhosted.org/packages/c2/4b/62d5bc1a46a0d446211b23203d05d8ebfd0653504105b0430a64aa9abad8/jsonvice-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-11 03:48:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "deftio",
    "github_project": "jsonvice",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "jsonvice"
}
        
Elapsed time: 0.34482s