Skip to main content

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.

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


Download files

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

Source Distribution

json-operator-0.0.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_operator-0.0.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file json-operator-0.0.1.tar.gz.

File metadata

  • Download URL: json-operator-0.0.1.tar.gz
  • Upload date:
  • Size: 5.1 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

Hashes for json-operator-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3b1b60f711eeb0a0c9520c3ec72ad45b9cd7a758e03978531313f97552d1b9b5
MD5 667d80a870a107f9618828239c78e36e
BLAKE2b-256 63fd5469095b3bb36d739462899a0c706d668dff12046790a2d5b7a9ecb1b881

See more details on using hashes here.

File details

Details for the file json_operator-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: json_operator-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 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

Hashes for json_operator-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7f1a555ab536825daaddac993319cd4fb6151af74021d6ed80276c48293d5d
MD5 39e3bc1be4cc54d3eef0bb384284fc2a
BLAKE2b-256 ba74734dd31b9f2ea9f6ac2a21719fc0721de3bc7c3609107c828acc47900cbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page