A Python validator for the JSON-stat 2.0 standard format, based on Pydantic.
Project description
JSON-stat Validator
A Python validator for the JSON-stat 2.0 standard format, based on Pydantic.
JSON-stat is a simple lightweight format for data interchange. It is a JSON format for data dissemination that allows the representation of statistical data in a way that is both simple and convenient for data processing. With this validator, you can ensure your data conforms to the official JSON-stat 2.0 specification.
Disclaimer
This is a non-official implementation of the JSON-stat validator. The official validator can be found at json-stat.org/format/validator/.
Please note that this implementation is intentionally more strict than the official validator, as it applies all limitations and logical rules mentioned in the specification. For example:
{
"id": ["country", "year", "age", "concept", "sex"],
"size": [1, 2]
}
This dataset would be considered valid by the official JSON-stat validator tool, but will fail validation in this package because it violates the rule in the dataset.size section of the specification stating that: size has the same number of elements and in the same order as in id.
Additionally, we enforce the role field as required when class=dataset.
Table of Contents
- Installation
- Quick Start
- Key Features
- Usage Examples
- Testing
- Development
- Contributing
- License
- Credits
Installation
pip install jsonstat-validator
Quick Start
Validate a JSON-stat object with a single function call. See the samples/quickstart.py file for a complete example.
Key Features
- Validates JSON-stat data against the full 2.0 specification
- Provides models for all major JSON-stat classes: Dataset, Dimension, Collection
- Built on Pydantic for robust type validation and detailed error messages
- Provides tests against the official JSON-stat samples and custom fine-grained tests
Usage Examples
Code examples can be found in the examples/ directory.
Testing
The validator has been thoroughly tested with all official JSON-stat samples from the JSON-stat website.
To run tests:
# Install development dependencies
pip install jsonstat-validator[dev]
# Run all tests
pytest
# Run specific tests
pytest tests/test_official_samples.py
Development
Local Development Setup
For local development:
# Clone the repository
git clone https://github.com/YOUR-USERNAME/jsonstat-validator.git
cd jsonstat-validator
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
Creating a New Release
- Create a new release on GitHub with a tag in the format
vX.Y.Z
The GitHub Actions workflow will automatically:
- Run tests
- Build the package
- Update version numbers in both
__init__.pyandpyproject.toml - Publish the package to PyPI
- Update the CHANGELOG.md with the release date and commit messages
Contributing
We welcome contributions to the JSON-stat Validator! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For more details, please see our CONTRIBUTING.md file.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
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 jsonstat_validator-0.1.3.tar.gz.
File metadata
- Download URL: jsonstat_validator-0.1.3.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
275b3f22fb9f1a601668fcbc5fbb2795accb68ed74c8eeed2e94fd808c16fdbd
|
|
| MD5 |
b6b665fc6b2cd22e64ae1bf5935dccb4
|
|
| BLAKE2b-256 |
bc5d51b67fb538ed83c18d29db1de1ac8ad899751a6446bf3a9f0c2320e1da69
|
Provenance
The following attestation bundles were made for jsonstat_validator-0.1.3.tar.gz:
Publisher:
workflow.yml on ahmed-hassan19/jsonstat-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonstat_validator-0.1.3.tar.gz -
Subject digest:
275b3f22fb9f1a601668fcbc5fbb2795accb68ed74c8eeed2e94fd808c16fdbd - Sigstore transparency entry: 183366870
- Sigstore integration time:
-
Permalink:
ahmed-hassan19/jsonstat-validator@e7e1df8db5e771475e737e36f74c96695e63eaef -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/ahmed-hassan19
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@e7e1df8db5e771475e737e36f74c96695e63eaef -
Trigger Event:
release
-
Statement type:
File details
Details for the file jsonstat_validator-0.1.3-py3-none-any.whl.
File metadata
- Download URL: jsonstat_validator-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95b9cdadac9d70e4068b2c17f3f6b532f4cc702a87f8346eb06642389a32a20e
|
|
| MD5 |
eb768b1a79a24761fb596b19673488eb
|
|
| BLAKE2b-256 |
e4bb02ffbafe2d730fa8d3126ff8fabccbc5ac31a676c66b6bab43183b556cfc
|
Provenance
The following attestation bundles were made for jsonstat_validator-0.1.3-py3-none-any.whl:
Publisher:
workflow.yml on ahmed-hassan19/jsonstat-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonstat_validator-0.1.3-py3-none-any.whl -
Subject digest:
95b9cdadac9d70e4068b2c17f3f6b532f4cc702a87f8346eb06642389a32a20e - Sigstore transparency entry: 183366872
- Sigstore integration time:
-
Permalink:
ahmed-hassan19/jsonstat-validator@e7e1df8db5e771475e737e36f74c96695e63eaef -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/ahmed-hassan19
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@e7e1df8db5e771475e737e36f74c96695e63eaef -
Trigger Event:
release
-
Statement type: