Skip to main content

A Python validator for the JSON-stat 2.0 standard format, based on Pydantic.

Reason this release was yanked:

Diverted from the standard, see changelog for details.

Project description

JSON-stat Validator

PyPI version Python Version License

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.

Table of Contents

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

  1. 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__.py and pyproject.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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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

  • JSON-stat - For creating and maintaining the JSON-stat standard
  • Pydantic - For the data validation framework

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonstat_validator-0.1.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonstat_validator-0.1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file jsonstat_validator-0.1.1.tar.gz.

File metadata

  • Download URL: jsonstat_validator-0.1.1.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jsonstat_validator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cdab6cceaf1143a3d5f48c345f0b448f1c8549d7b754f1befe7af2641d2ef0e1
MD5 cdd5282ffcdab5903b23cde6294caa66
BLAKE2b-256 a56e1825d1b5fca352053de018f80ff1dd07fb7b42db691aad5f0ee16a33b47a

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonstat_validator-0.1.1.tar.gz:

Publisher: workflow.yml on ahmed-hassan19/jsonstat-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jsonstat_validator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jsonstat_validator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf79b7086bef080465a8a02518960421c6f4c03dc2772d9da6bece314116b110
MD5 40f06daabfd12855214ebf1a0b92dbaf
BLAKE2b-256 5ff45e260e41a7ed903bba3f8fd63cfa6f8e7a4a3a82896d0ba2e9d1609c8441

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonstat_validator-0.1.1-py3-none-any.whl:

Publisher: workflow.yml on ahmed-hassan19/jsonstat-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page