A recursive json comparison library that handles karate style json comparison
Project description
json_compare
A library to compare any json string/lists/json-like-objects primarily for tests which are using Karate Style Matching rules and templates (https://github.com/karatelabs/karate?tab=readme-ov-file#fuzzy-matching)
Version 1.0: First version.
Features
- Compare jsons (recursion supported). Useful for interface testing.
- Compare lists out of order. In order compare is not supported yet.
- Supports Python >=3.5.
- Supports skipping of optional keys using ##object in the expected/template JSON
- Checks if input is valid JSON object before starting the comparison
QuickStart
install
pip install jsoncomparekarate
or update
pip install -U jsoncomparekarate
a simple example
from jsoncomparekarate import compare
print(compare({"key1":["v1","v2"],"key2":{"key3":1}},{"key1":["v2","v1"],"key2":{"key3":2}}))
to see
a is {'key1': ['v1', 'v2'], 'key2': {'key3': 1}}
b is {'key1': ['v2', 'v1'], 'key2': {'key3': 2}}
False
For more demos and information, just install it and visit the test file test_json_compare.py in Your_Python_Path/Lib/site-packages/json_compare_karate/
Bug report
- Issues and bugs report to eatfrogfirst@outlook.com.
- Homepage icon leads to my Github project page, issues / PRs / stars are welcomed :)
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-compare-karate-1.0.tar.gz.
File metadata
- Download URL: json-compare-karate-1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22d898b50aeba44eeaa0cdb74810be57a1da6acf23de0cac511d04e8074ba87c
|
|
| MD5 |
f73006772519813162eb0827783a8cce
|
|
| BLAKE2b-256 |
dd83ce23e643634b7e7826ed45522a47e918fcd3c08f76494cc4fda8a0900de2
|
File details
Details for the file json_compare_karate-1.0-py3-none-any.whl.
File metadata
- Download URL: json_compare_karate-1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5c303d1837c48fa20715a883fa0adeba762a229dc862372a8463dd5e66ceace
|
|
| MD5 |
b05b1dde7b25df3ad38aa08662ed641b
|
|
| BLAKE2b-256 |
9a93378dd41ba25913ce5b2f2897b599f44112c8164a3c466ba046bc5ebcea6a
|