{"id":28247062,"url":"https://github.com/maspe36/json_typer","last_synced_at":"2025-07-04T01:05:11.696Z","repository":{"id":62572973,"uuid":"141848215","full_name":"maspe36/json_typer","owner":"maspe36","description":"Seamlessly encode and decode python objects to json while maintaining their types.","archived":false,"fork":false,"pushed_at":"2018-12-01T20:08:24.000Z","size":22,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-19T10:08:35.886Z","etag":null,"topics":["dynamic-typing","json","library","types"],"latest_commit_sha":null,"homepage":"","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/maspe36.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}},"created_at":"2018-07-21T21:53:36.000Z","updated_at":"2022-03-25T18:51:09.000Z","dependencies_parsed_at":"2022-11-03T17:30:31.671Z","dependency_job_id":null,"html_url":"https://github.com/maspe36/json_typer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/maspe36/json_typer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maspe36%2Fjson_typer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maspe36%2Fjson_typer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maspe36%2Fjson_typer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maspe36%2Fjson_typer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maspe36","download_url":"https://codeload.github.com/maspe36/json_typer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maspe36%2Fjson_typer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259922378,"owners_count":22932501,"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":["dynamic-typing","json","library","types"],"created_at":"2025-05-19T10:08:33.420Z","updated_at":"2025-06-15T04:31:45.119Z","avatar_url":"https://github.com/maspe36.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json_typer\nSeamlessly encode and decode python objects to json while maintaining their types.\n\n## Installation\n`pip install json_typer`\n\n## Usage\n### Making a class type serializable\nTo make a class type serializable (a.k.a to seamlessly serialize the class to JSON and then when loading the JSON convert the object to its old type) inherit from ```TypeSerializable``` and make sure you are passing ```*args, **kwargs``` to the super constructor.\n```python\nfrom json_typer import TypeSerializable\n\n\nclass Foo(TypeSerializable):\n    def __init__(bar, baz=\"\", *args, **kwargs):\n        self.bar = bar\n        self.baz = baz\n```\n\n### Exporting a type serializable class\n```python\nfrom json_typer import io\n\nfoo = Foo(bar=\"example\")\n\nio.exportJSON(path=EXAMPLE_FILE, data=foo)\n```\n\nEXAMPLE_FILE contents\n```javascript\n{\n    \"type\": \"Foo\"\n    \"module\": \"Foo\"\n    \"bar\": \"example\",\n    \"baz\": \"\"\n}\n```\n\n### Importing a JSON file\n```python\nfrom json_typer import io\n\n\nfoo = io.loadJSON(path=EXAMPLE_FILE)\n```\n\nAccess the loaded attributes like you normally would\n```python\nfoo.bar\n\u003e\u003e\u003e example\n\nisinstance(foo, Foo)\n\u003e\u003e\u003e True\n```\n\n## Running Tests\nOpen a terminal in this projects root directory and type ```python -m unittest```\n\n## Limitations\n- Must have ```*args, **kwargs``` in the constructor and passed to the super call in any class that inherits from ```TypeSerializable```\n- A class that inherits from ```TypeSerializable``` cannot implement ```_type``` or ```_module``` attributes\n\n## Authors\n* **Sam Privett** - *Initial work* - [maspe36](https://github.com/maspe36)\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaspe36%2Fjson_typer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaspe36%2Fjson_typer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaspe36%2Fjson_typer/lists"}