{"id":19620601,"url":"https://github.com/ohmajesticlama/jsonloader","last_synced_at":"2025-04-28T03:32:06.771Z","repository":{"id":43940127,"uuid":"453806445","full_name":"OhMajesticLama/jsonloader","owner":"OhMajesticLama","description":"No more boilerplate to check and build a Python object from JSON.","archived":false,"fork":false,"pushed_at":"2023-04-18T16:06:26.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T05:51:09.325Z","etag":null,"topics":["csv","json","python","typing"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/jsonloader/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OhMajesticLama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-30T21:27:12.000Z","updated_at":"2023-07-25T15:03:04.000Z","dependencies_parsed_at":"2024-11-11T11:19:45.766Z","dependency_job_id":"b8082ac6-dd2e-4b05-a7bf-6649bbaea0db","html_url":"https://github.com/OhMajesticLama/jsonloader","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":"0.42105263157894735","last_synced_commit":"948ec48f15e790851fc6b201d1c9da31c6efb431"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OhMajesticLama%2Fjsonloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OhMajesticLama%2Fjsonloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OhMajesticLama%2Fjsonloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OhMajesticLama%2Fjsonloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OhMajesticLama","download_url":"https://codeload.github.com/OhMajesticLama/jsonloader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251246151,"owners_count":21558759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","json","python","typing"],"created_at":"2024-11-11T11:19:23.807Z","updated_at":"2025-04-28T03:32:06.765Z","avatar_url":"https://github.com/OhMajesticLama.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSONloader\n[![Downloads](https://pepy.tech/badge/jsonloader)](https://pepy.tech/project/jsonloader)\n[![CI](https://github.com/OhMajesticLama/jsonloader/actions/workflows/lint-and-tests.yml/badge.svg)](https://github.com/OhMajesticLama/jsonloader/actions/workflows/lint-and-tests.yml)\n\nThis module is for you if you're tired of writing boilerplate that:\n- builds a straightforward Python object from loaded JSON or similar dict-based\n  data loading (e.g. CSV).\n- checks that your input-loaded-JSON has all necessary attributes for your pipeline.\n- checks that your input JSON has the right types.\n\n\n## Examples\nMain intended usage is through the `JSONclass` decorator, example below:\n\nBy default we don't check for anything, we just build the object\nas we received it.\n```python\n\u003e\u003e\u003e from jsonloader import JSONclass\n\u003e\u003e\u003e data = {'a': 'aa', 'b': 'bb', 'c': 1}\n\u003e\u003e\u003e @JSONclass\n... class Example:\n...     pass\n...\n\u003e\u003e\u003e example = Example(data)\n\u003e\u003e\u003e example.a\n'aa'\n\u003e\u003e\u003e example.b\n'bb'\n```\n\nWe want to ensure we have annotated parameters\n```python\n\u003e\u003e\u003e from jsonloader import JSONclass\n\u003e\u003e\u003e data = {'a': 'aa', 'b': 'bb', 'c': 1}\n\u003e\u003e\u003e @JSONclass(annotations=True)\n... class Example:\n...     a: str\n...     d: int\n...\n\u003e\u003e\u003e try:\n...     example = Example(data)\n... except KeyError:\n...     print(\"error - missing 'd'\")\n...\nerror - missing 'd'\n\u003e\u003e\u003e data['d'] = 1  # Let's fix the missing data\n\u003e\u003e\u003e example = Example(data)  # No more error in loading.\n```\n\nWe want to ensure we have *only* annotated parameters\n```python\n\u003e\u003e\u003e from jsonloader import JSONclass\n\u003e\u003e\u003e data = {'a': 'aa', 'b': 'bb', 'c': 1}\n\u003e\u003e\u003e @JSONclass(annotations=True, annotations_strict=True)\n... class Example:\n...     a: str\n...     b: int\n...\n\u003e\u003e\u003e try:\n...     example = Example(data)\n... except KeyError:\n...     print(\"error - extra 'c'\")\n...\nerror - extra 'c'\n\u003e\u003e\u003e del data['c']  # Let's remove unwanted data\n\u003e\u003e\u003e example = Example(data)  # No more error in loading.\n```\n\nWe want to ensure we have only annotated parameters and they\nare of annotated type.\n```python\n\u003e\u003e\u003e from jsonloader import JSONclass\n\u003e\u003e\u003e data = {'a': 'aa', 'b': 'bb'}\n\u003e\u003e\u003e @JSONclass(annotations_strict=True, annotations_type=True)\n... class Example:\n...     a: str\n...     b: int\n...\n\u003e\u003e\u003e try:\n...     example = Example(data)\n... except TypeError:\n...     print(\"error - b is not int\")\n...\nerror - b is not int\n```\n\nDefault values are supported too.\n```python\n\u003e\u003e\u003e from jsonloader import JSONclass\n\u003e\u003e\u003e data = {'a': 'aa'}\n\u003e\u003e\u003e @JSONclass(annotations_strict=True, annotations_type=True)\n... class Example:\n...     a: str\n...     b: int = 1\n...\n\u003e\u003e\u003e example = Example(data)\n\u003e\u003e\u003e example.b\n1\n```\n\nA JSONclass can be converted back to a dict, even for recursive\nstructures\n```python\n\u003e\u003e\u003e from jsonloader import JSONclass\n\u003e\u003e\u003e data = {'a': 'aa', 'b':2, 'c': {'foo': 'bar'}}\n\u003e\u003e\u003e @JSONclass(annotations_type=True, annotations=True)\n... class Example:\n...     a: str\n...     b: int\n...\n\u003e\u003e\u003e example = Example(data)\n\u003e\u003e\u003e assert dict(example) == data\n```\n\n## Install\n\n### User installation\n```\n# Recommendation: install jsonloader in your project virtualenv\n# Should you not want to use virtualenv or equivalent, it's recommended to use\n# '--user' pip option to avoid a system-level install.\npip3 install jsonloader\n```\n\n### Developer installation\n\nGithub repository currently points to latest development version. Please\njump to latest released version tag if you intend to work on PyPI version.\nFor example `git checkout tags/v0.4.3`.\n\n```\n# These commands assume virtualenv is installed\npython3 -m virtualenv venv\n. venv/bin/activate\n\n# Actually install the deps\npip3 install -e '.[dev]'\n\n# To setup the project's git hooks:\ngit config --local core.hooksPath hook\n```\n\n## Run Tests\n\n```\n# From this repository top directory\npytest --doctest-modules\n```\n\n### Tests coverage\nFor example, leverage `coverage` module:\n```\ncoverage run -m pytest --doctest-modules\ncoverage html\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohmajesticlama%2Fjsonloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohmajesticlama%2Fjsonloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohmajesticlama%2Fjsonloader/lists"}