You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@
5
5
6
6
# About jsonvice
7
7
8
-
jsonvice is small command line tool (cli) for minifying JSON but with optimal precision truncation/rounding. In many applications floating point values in JSON can be very long (15 digits) but this level of accuracy isn't needed and takes up much space.
8
+
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.
9
9
10
-
jsonvice allows the truncation of all the embedded floating point numbers to a specified number of digits.
10
+
jsonvice allows the truncation of all the embedded floating point numbers (wherever they appear) to a specified number of digits.
11
11
12
-
It also removes unencessary white space to help minify JSON files. However there are many tools that can minify JSON.
12
+
It also removes unnecessary white space to minify JSON files.
13
13
14
-
input.json
14
+
sample_input.json
15
15
```json
16
16
{
17
17
"x" : 12.32,
@@ -21,7 +21,7 @@ input.json
21
21
}
22
22
```
23
23
24
-
run jsonvice
24
+
now run jsonvice
25
25
```sh
26
26
jsonvice -i input.json -o output.json -p 4
27
27
```
@@ -36,7 +36,7 @@ ouput.json
36
36
37
37
compactify json and reduce floating point precision to max of 5 digits by rounding
38
38
```shell
39
-
jsonvice -i myfile.json -o output.json -p 5
39
+
jsonvice -i sample_input.json -o output.json -p 5
40
40
```
41
41
42
42
compactify json and reduce floating point precision to max of 5 digits by rounding down
pipx can be used to install an isolated version of jsonvice as a command line tool.
79
+
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.)
Python version 3.6 or higher is required to build jsonvice. If pipx is used for install isolation takes place automatically.
99
99
100
100
# Testing
101
-
poetry run pytest
101
+
Both pytest and tox were used to build jsonvice. Testing can be performed at the command line via either tool:
102
102
103
+
```sh
104
+
poetry run pytest
105
+
```
103
106
or
104
-
107
+
```sh
105
108
tox
109
+
```
106
110
107
111
# History & Motivation
108
112
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.
109
113
110
114
At the time couldn't find a tool and whipped up small script (the original script is in /dev directory).
111
115
112
-
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.
116
+
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.
0 commit comments