JSONLibconfig
✨ Pure python implementation library provides JSON <- convert -> Libconfig
Install
pip install jsonlibconfig
CLI Usage
λ ~/jsonlibconfig -h
usage: jsonlibconfig [-h] [--target {json,libconfig}] [--pretty] [--hextoint]
[--file FILE]
Pure python library provides JSON <- convert --> Libconfig
optional arguments:
-h, --help show this help message and exit
--target {json,libconfig}
specify output format: json, libconfig (default:
libconfig)
--pretty Pretty print
--hextoint Convert HEX string to integer (only for json)
--file FILE Input file
JSON to Libconfig
cat example.cfg | jsonlibconfig --target json
{"hours": {"mon": {"close": 18, "open": 9}, "wed": {"close": 18, "open": 9}, "sun": {"close": 16, "open": 11}, "fri": {"close": 20, "open": 9}, "sat": {"close": 20, "open": 9}, "thu": {"close": 18, "open": 9}, "tue": {"close": 18, "open": 9}}, "name": "Books, Movies & More", "inventory": {"movies": [{"media": "DVD", "price": 19.99, "qty": 11, "title": "Brazil"}, {"media": "DVD", "price": 18.99, "qty": 5, "title": "The City of Lost Children"}, {"media": "Blu-Ray", "price": 24.99, "qty": 20, "title": "Memento"}, {"title": "Howard the Duck"}], "books": [{"price": 29.99, "author": "Robert Louis Stevenson", "qty": 5, "title": "Treasure Island"}, {"price": 9.99, "author": "Neal Stephenson", "qty": 8, "title": "Snow Crash"}]}}
Libconfig to JSON
cat example.json | jsonlibconfig --pretty
hours = {
wed = {
close = 18;
open = 9;
};
sun = {
close = 16;
open = 11;
};
fri = {
close = 20;
open = 9;
};
tue = {
close = 18;
open = 9;
};
mon = {
close = 18;
open = 9;
};
thu = {
close = 18;
open = 9;
};
sat = {
close = 20;
open = 9;
};
};
name = "Books, Movies & More";
inventory = {
movies = (
{
media = "DVD";
price = 19.99;
title = "Brazil";
qty = 11;
},
{
media = "DVD";
price = 18.99;
title = "The City of Lost Children";
qty = 5;
},
{
media = "Blu-Ray";
price = 24.99;
title = "Memento";
qty = 20;
},
{
title = "Howard the Duck";
}
);
books = (
{
title = "Treasure Island";
price = 29.99;
qty = 5;
author = "Robert Louis Stevenson";
},
{
title = "Snow Crash";
price = 9.99;
qty = 8;
author = "Neal Stephenson";
}
);
};
API
from jsonlibconfig import encoder
from jsonlibconfig import decoder
from json to libconfig
encoder.dumps(json.loads(inputs))
from libconfig to json
decoder.loads(inputs))
License
Metadata
Release files for jsonlibconfig 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jsonlibconfig-0.1.0.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jsonlibconfig-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.3 kB
Release files / jsonlibconfig-0.1.0.tar.gz
| Download URL | jsonlibconfig-0.1.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f677ce4913841509a2860f1c101413738f1067cd74d11ae8bd771d7f775dc634
|
|
BLAKE2b-256 checksum How to use checksums |
b129cc50726e89e16c51b58631835e634bf3bdd867b903d8311e8c1619689df8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.8.0
|
Release files / jsonlibconfig-0.1.0-py3-none-any.whl
| Download URL | jsonlibconfig-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86bc682db8c7074cb655c6eb4cf2c4181e94a6b595903a6cae68fbf2f402c2a3
|
|
BLAKE2b-256 checksum How to use checksums |
046dc829f84ddc2c9a36a4ba7266570faad13f8de2c61928bd039a5dc8ad25f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.8.0
|