A library to operate on JSON objects
Project description
json-operator is a tool which provides operations on JSON data.
If a JSON object is regarded as a data set (key-value pair), we can apply set operations on it. An example is to find out all the common attributes in two JSON objects. Another example is to check if two JSON objects are equal or not.
Currently json-operator supports 4 operations: equal, intersection, union, subtract.
Installation
$ pip install json-operator
Embedded examples
json-operator can be embedded into your program as a library.
import json_operator as jo
import json
# construct JSON objects
obj1 = json.loads('{"a": 1, "b":2}')
obj2 = json.loads('{"a": 1, "c":"3"}')
# equal operation
res = jo.equal(obj1, obj2) # False
# intersection
res = jo.intersection(obj1, obj2) # {"a":1}
# union
res = jo.union(obj1, obj2) # {"a":1, "b":2, "c":"3"}
# subtract
res = jo.subtract(obj1, obj2) # {"b":2}
res = jo.subtract(obj2, obj1) # {"c":"3"}
Standalone usage
$ json-operator --help
usage: json-operator [--lt LT] [--rt RT] [--lf LF] [--rf RF] [--out OUT] [--help] [operator]
command utility to operate on JSON objects. Supported operators: equal, intersection, subtract, union.
positional arguments:
operator action command
optional arguments:
--lt LT left-side JSON text. Overwrite --lf option
--rt RT right-side JSON text. Overwrite --rf option
--lf LF left-side file where JSON is stored
--rf RF right-side file where JSON is stored
--out OUT output file. Default is stdout
--help print this help message
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json-operator-0.0.6.tar.gz.
File metadata
- Download URL: json-operator-0.0.6.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3ab764091994dbcf2b6c0b282845095c64fe433f88744a47ce1c60918f09ea6
|
|
| MD5 |
c2cca69e40d0ef56c85c404142b19829
|
|
| BLAKE2b-256 |
bb97e32a617408264dfb9f2da3ea8ab1c246a6b71149bd2e2cea79178f11d620
|
File details
Details for the file json_operator-0.0.6-py3-none-any.whl.
File metadata
- Download URL: json_operator-0.0.6-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7201123d44bf75255d96deda28ae3cb4ca12fbb01174310429d6adbd74a35f1
|
|
| MD5 |
4f51527372413fb786066f4dd311aeeb
|
|
| BLAKE2b-256 |
38e3d32512cae296b945f7701df9a489df097057eb4d3027e97737106365604c
|