Registry / serialization / pyjson

pyjson

JSON →
library1.4.1pypypi✓ verified 87d ago

A library to compare the similarity between two JSON objects, supporting custom thresholds, exclusion of fields, and handling of arrays. Current version 1.4.1 (PyPI) and up to 1.4.5 on GitHub. Maintenance status is unclear.

pip install pyjson
INSTALL
IMPORT
SIG · PYJSON
P
pyjson
serializationpythonv1.4.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compare
from pyjson import compare
import pyjson
Importing pyjson alone does not expose compare directly; use from pyjson import compare.

Basic usage: compare two JSON objects. Returns a dict with similarity score.

from pyjson import compare json1 = {'a': 1, 'b': 2} json2 = {'a': 1, 'b': 3} result = compare(json1, json2) print(result) # Output: 0.5 expected = {'score': 0.5} print(result == expected) # True
Debug
Known issues
gotchaThe compare function returns a dict, not a float. Access score via result['score'].
fix
Use result['score'] to get similarity value.
affects: >=1.0.0
gotchaThe library does not handle NaN or Infinity values; they may cause unexpected behavior or errors.
fix
Sanitize JSON inputs to avoid NaN/Infinity.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyjson'
The library is not installed or is installed in a different environment.
fix
Run 'pip install pyjson' in the correct environment.
AttributeError: module 'pyjson' has no attribute 'compare'
The correct import is 'from pyjson import compare'.
fix
Replace 'import pyjson' with 'from pyjson import compare'.
Upgrade
Version history
1.4.1latest on PyPI · released Sep 21, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
pyjson — pip install pyjson · libregistry