A lightweight and efficient JSON validation tool for Python.
Project description
# JSONEyeX: Effortless JSON Data Validation in Python
JSONEyeX is a robust and user-friendly Python package that streamlines the process of validating JSON data against predefined schemas. Whether you're building web APIs, managing data pipelines, or developing in JSON-heavy environments, JSONEyeX ensures your data adheres to the specified format and types, enhancing the reliability and efficiency of your projects.
Key Features:
- Comprehensive validation: Handles various data types, nested structures, and custom validations.
- Clear error messages: Simplifies debugging with informative and descriptive feedback.
- Seamless integration: Easily integrates into existing Python projects.
Ideal Use Cases:
- Data cleansing and verification in web APIs.
- Ensuring data integrity in data pipelines and processing tasks.
- Rapid development in projects with extensive JSON data usage.
Get Started with JSONEyeX:
- Install
JSONEyeXusingpip install JSONEyeX. - Define your JSON schema using Python dictionaries.
- Validate your data against the schema with
jsonvalidatorfunction.
Example 1: Validating a Simple JSON Object:
schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"},
"address": {
"type": "object",
"properties": {
"street": {"type": "string"},
"city": {"type": "string"}
},
"required": ["street", "city"]
}
},
"required": ["name", "age", "address"]
}
data = {
"name": "John Doe",
"age": 30,
"address": {
"street": "123 Main St",
"city": "Anytown"
}
}
from JSONEyeX import jsonvalidator
try:
validator = jsonvalidator(schema, data)
print("Validation successful! Your data conforms to the expected format.")
except ValueError as e:
print(f"Validation error: {e}")
Example 2: Handling Unknown Properties in Nested Objects
While defining nested JSON objects in your schema, sometimes you might not know or need to specify every possible property. JSONEyeX allows you to handle these unknown properties gracefully. Consider the "material_grade" object in our example schema. It has an empty "properties" list, indicating that any additional properties beyond "manufacturing_process" will be accepted without validation. However, note that the "material_grade" object itself is still required through the schema's "required" field.
schema = {
"type": "object",
"properties": {
"tolerance": {"type": "string"},
"quantity": {"type": "number"},
"surface_finish": {"type": "string"},
"material_grade": {
"type": "object",
"properties": {},
"required": [] # No specific properties required, but object itself is mandatory
},
"material_group": {
"type": "object",
"properties": {
"data": {"type": "string"}
},
"required": ["data"]
}
},
"required": [
"tolerance",
"quantity",
"surface_finish",
"material_grade"
]
}
data = {
"tolerance": "0.1mm",
"quantity": 100,
"surface_finish": "matte",
"material_grade": {"manufacturing_process": "3D printing", "additional_property": "value"},
"material_group": {"data": "Sample material group data"}
}
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 JSONEyeX-0.0.10.tar.gz.
File metadata
- Download URL: JSONEyeX-0.0.10.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82bc6eff9030afae8c384d61de41c71bebfb1eca62135fbfdb8baea9c190f48d
|
|
| MD5 |
4e5d8d499ca19820875f6a0effa0f682
|
|
| BLAKE2b-256 |
ff662ea079deaa18abe57ec60bcc3605043aa10d61e4b82a668a93f004f9d124
|
File details
Details for the file JSONEyeX-0.0.10-py3-none-any.whl.
File metadata
- Download URL: JSONEyeX-0.0.10-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aa745d88294d103f81f1824dec3b202cc78222081cc911199cc6f656732f146
|
|
| MD5 |
a2a9a7d4e4de97bbdec2a6ef72a6612b
|
|
| BLAKE2b-256 |
5e9bbe459557c655575754b754ae3dd6cfcf364661acadf8669ec1e99c1f1110
|