https://github.com/bharat23/json-schema-filter
A library that uses json schema to filter the objects
https://github.com/bharat23/json-schema-filter
filter jsonschema
Last synced: about 1 month ago
JSON representation
A library that uses json schema to filter the objects
- Host: GitHub
- URL: https://github.com/bharat23/json-schema-filter
- Owner: Bharat23
- License: mit
- Created: 2023-12-25T22:03:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-01T17:45:28.000Z (about 1 year ago)
- Last Synced: 2025-02-03T00:28:23.530Z (5 months ago)
- Topics: filter, jsonschema
- Language: Python
- Homepage: https://pypi.org/project/json-schema-filter/
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-schema-filter
[](https://badge.fury.io/py/json-schema-filter)
A library that uses `jsonschema` to filter the objects
### Usage
```python
from json_schema_filter import JsonSchemaFilterschema = {
"properties": {
"name": {
"type": "string",
"equals": "Shakespeare"
}
},
"required": ["name"]
}input_data = [
{"name": "what is in the name"},
{"name": "Shakespeare"},
{"name": "hamlet"},
]print(JsonSchemaFilter(schema).filter(input_data))
# output
"""
Total Selected: 1
Filtered Item: [0]
1. name: Values not equal. Expected: Shakespeare, Found: what is in the name
Filtered Item: [2]
1. name: Values not equal. Expected: Shakespeare, Found: hamlet
"""
```### Supported additional properties
|Property|Supported type|Description|
|--------|--------------|-----------|
|equals|*|Check if value matches
|iequals|string|Check if value matches (case insensitive)
|nequals|*|Check if value does not match