jsonstat-validator


Namejsonstat-validator JSON
Version 0.2.2 PyPI version JSON
download
home_pageNone
SummaryA Python validator for the JSON-stat 2.0 standard format, based on Pydantic.
upload_time2025-07-20 03:04:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
license# MIT License Copyright (c) 2025 JSON-stat Validator Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords json-stat validator json data-engineering pydantic python fao
VCS
bugtrack_url
requirements pydantic
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # JSON-stat Validator

[![PyPI version](https://img.shields.io/pypi/v/jsonstat-validator.svg)](https://pypi.org/project/jsonstat-validator/)
[![Python Version](https://img.shields.io/pypi/pyversions/jsonstat-validator.svg)](https://pypi.org/project/jsonstat-validator/)
[![License](https://img.shields.io/github/license/ahmed-hassan19/jsonstat-validator.svg)](https://github.com/ahmed-hassan19/jsonstat-validator/blob/main/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](https://json-stat.org/full/).

## Disclaimer

This is a non-official implementation of the JSON-stat validator. The official validator can be found at [json-stat.org/format/validator/](https://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:

```json
{
    "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](#installation)
- [Quick Start](#quick-start)
- [Key Features](#key-features)
- [Usage Examples](#usage-examples)
- [Testing](#testing)
- [Development](#development)
  - [Local Development Setup](#local-development-setup)
  - [Creating a New Release](#creating-a-new-release)
- [Contributing](#contributing)
- [License](#license)
- [Credits](#credits)

## Installation

```bash
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](https://json-stat.org/full)
- 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](https://json-stat.org/samples/collection.json) 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](https://json-stat.org/samples/).

To run tests:

```bash
# 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:

```bash
# 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. Update the `CHANGELOG.md`.
2. 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

## 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](.github/CONTRIBUTING.md) file.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Credits

- [JSON-stat](https://json-stat.org/) - For creating and maintaining the JSON-stat standard
- [Pydantic](https://pydantic-docs.helpmanual.io/) - For the data validation framework

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jsonstat-validator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "json-stat, validator, json, data-engineering, pydantic, python, fao",
    "author": null,
    "author_email": "Ahmed Hassan <ahmedhassan.ahmed@fao.org>",
    "download_url": "https://files.pythonhosted.org/packages/26/86/e3e296d920e2d5a891e0bc4c64659c75999cdd7433e1552b38d2a0022f72/jsonstat_validator-0.2.2.tar.gz",
    "platform": null,
    "description": "# JSON-stat Validator\n\n[![PyPI version](https://img.shields.io/pypi/v/jsonstat-validator.svg)](https://pypi.org/project/jsonstat-validator/)\n[![Python Version](https://img.shields.io/pypi/pyversions/jsonstat-validator.svg)](https://pypi.org/project/jsonstat-validator/)\n[![License](https://img.shields.io/github/license/ahmed-hassan19/jsonstat-validator.svg)](https://github.com/ahmed-hassan19/jsonstat-validator/blob/main/LICENSE)\n\nA Python validator for the JSON-stat 2.0 standard format, based on Pydantic.\n\nJSON-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](https://json-stat.org/full/).\n\n## Disclaimer\n\nThis is a non-official implementation of the JSON-stat validator. The official validator can be found at [json-stat.org/format/validator/](https://json-stat.org/format/validator/).\n\nPlease 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:\n\n```json\n{\n    \"id\": [\"country\", \"year\", \"age\", \"concept\", \"sex\"],\n    \"size\": [1, 2]\n}\n```\n\nThis 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`.\n\nAdditionally, we enforce the `role` field as required when `class=dataset`.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Key Features](#key-features)\n- [Usage Examples](#usage-examples)\n- [Testing](#testing)\n- [Development](#development)\n  - [Local Development Setup](#local-development-setup)\n  - [Creating a New Release](#creating-a-new-release)\n- [Contributing](#contributing)\n- [License](#license)\n- [Credits](#credits)\n\n## Installation\n\n```bash\npip install jsonstat-validator\n```\n\n## Quick Start\n\nValidate a JSON-stat object with a single function call. See the `samples/quickstart.py` file for a complete example.\n\n## Key Features\n\n- Validates JSON-stat data against the [full 2.0 specification](https://json-stat.org/full)\n- Provides models for all major JSON-stat classes: **Dataset**, **Dimension**, **Collection**\n- Built on Pydantic for robust type validation and detailed error messages\n- Provides tests against the [official JSON-stat samples](https://json-stat.org/samples/collection.json) and custom fine-grained tests\n\n## Usage Examples\n\nCode examples can be found in the `examples/` directory.\n\n## Testing\n\nThe validator has been thoroughly tested with all official JSON-stat samples from the [JSON-stat website](https://json-stat.org/samples/).\n\nTo run tests:\n\n```bash\n# Install development dependencies\npip install jsonstat-validator[dev]\n\n# Run all tests\npytest\n\n# Run specific tests\npytest tests/test_official_samples.py\n```\n\n## Development\n\n### Local Development Setup\n\nFor local development:\n\n```bash\n# Clone the repository\ngit clone https://github.com/YOUR-USERNAME/jsonstat-validator.git\ncd jsonstat-validator\n\n# Create and activate a virtual environment\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n\n# Install in development mode\npip install -e \".[dev]\"\n\n# Run tests\npytest\n```\n\n### Creating a New Release\n\n1. Update the `CHANGELOG.md`.\n2. Create a new release on GitHub with a tag in the format `vX.Y.Z`\n\nThe GitHub Actions workflow will automatically:\n\n- Run tests\n- Build the package\n- Update version numbers in both `__init__.py` and `pyproject.toml`\n- Publish the package to PyPI\n\n## Contributing\n\nWe welcome contributions to the JSON-stat Validator! Here's how to get started:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nFor more details, please see our [CONTRIBUTING.md](.github/CONTRIBUTING.md) file.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Credits\n\n- [JSON-stat](https://json-stat.org/) - For creating and maintaining the JSON-stat standard\n- [Pydantic](https://pydantic-docs.helpmanual.io/) - For the data validation framework\n",
    "bugtrack_url": null,
    "license": "# MIT License\n        \n        Copyright (c) 2025 JSON-stat Validator Contributors\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "A Python validator for the JSON-stat 2.0 standard format, based on Pydantic.",
    "version": "0.2.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/ahmed-hassan19/jsonstat-validator/issues",
        "Documentation": "https://github.com/ahmed-hassan19/jsonstat-validator#readme",
        "Homepage": "https://github.com/ahmed-hassan19/jsonstat-validator"
    },
    "split_keywords": [
        "json-stat",
        " validator",
        " json",
        " data-engineering",
        " pydantic",
        " python",
        " fao"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "733bd9c61bc4ad7ce34250a7e8582e522eb32583f34437093801fbbcbcbbf1e9",
                "md5": "fb4df6aad1217d3990921e51172b36e4",
                "sha256": "f94e568957ef36955d4f8e84a3e6126d26bee52adc56612bbb5c06934bb834af"
            },
            "downloads": -1,
            "filename": "jsonstat_validator-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb4df6aad1217d3990921e51172b36e4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11845,
            "upload_time": "2025-07-20T03:04:23",
            "upload_time_iso_8601": "2025-07-20T03:04:23.197637Z",
            "url": "https://files.pythonhosted.org/packages/73/3b/d9c61bc4ad7ce34250a7e8582e522eb32583f34437093801fbbcbcbbf1e9/jsonstat_validator-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2686e3e296d920e2d5a891e0bc4c64659c75999cdd7433e1552b38d2a0022f72",
                "md5": "984452e8b4c5d22fa9ec7d1402bba9fc",
                "sha256": "56de96684b2636591dd381ae366ad9e5f22c496174b2c17d54023d42aca489d8"
            },
            "downloads": -1,
            "filename": "jsonstat_validator-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "984452e8b4c5d22fa9ec7d1402bba9fc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17000,
            "upload_time": "2025-07-20T03:04:24",
            "upload_time_iso_8601": "2025-07-20T03:04:24.753454Z",
            "url": "https://files.pythonhosted.org/packages/26/86/e3e296d920e2d5a891e0bc4c64659c75999cdd7433e1552b38d2a0022f72/jsonstat_validator-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-20 03:04:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ahmed-hassan19",
    "github_project": "jsonstat-validator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "2.11.2"
                ]
            ]
        }
    ],
    "lcname": "jsonstat-validator"
}
        
Elapsed time: 0.90955s