{"id":18863065,"url":"https://github.com/ramonhagenaars/jsons","last_synced_at":"2025-04-08T11:14:04.071Z","repository":{"id":32719519,"uuid":"140337655","full_name":"ramonhagenaars/jsons","owner":"ramonhagenaars","description":"🐍 A Python lib for (de)serializing Python objects to/from JSON","archived":false,"fork":false,"pushed_at":"2023-12-29T10:45:18.000Z","size":616,"stargazers_count":292,"open_issues_count":46,"forks_count":40,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-01T09:34:39.612Z","etag":null,"topics":["json","json-parser","pypi","python3","python35","python36","python37","serializable-objects","serialization","typehints"],"latest_commit_sha":null,"homepage":"https://jsons.readthedocs.io","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/ramonhagenaars.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":"2018-07-09T20:18:08.000Z","updated_at":"2025-03-27T06:45:20.000Z","dependencies_parsed_at":"2024-06-18T13:45:06.957Z","dependency_job_id":"578bb24c-78fc-4ede-8a0b-7d0ad461c7b2","html_url":"https://github.com/ramonhagenaars/jsons","commit_stats":{"total_commits":508,"total_committers":25,"mean_commits":20.32,"dds":0.687007874015748,"last_synced_commit":"9abbf3a3bd32435ac74bc98c3554ad3c71086036"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramonhagenaars%2Fjsons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramonhagenaars%2Fjsons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramonhagenaars%2Fjsons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramonhagenaars%2Fjsons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramonhagenaars","download_url":"https://codeload.github.com/ramonhagenaars/jsons/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829512,"owners_count":21002997,"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":["json","json-parser","pypi","python3","python35","python36","python37","serializable-objects","serialization","typehints"],"created_at":"2024-11-08T04:36:34.441Z","updated_at":"2025-04-08T11:14:04.047Z","avatar_url":"https://github.com/ramonhagenaars.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Python versions](https://img.shields.io/pypi/pyversions/jsons.svg)](https://img.shields.io/pypi/pyversions/jsons.svg)\n[![Downloads](https://pepy.tech/badge/jsons)](https://pepy.tech/project/jsons)\n[![PyPI version](https://badge.fury.io/py/jsons.svg)](https://badge.fury.io/py/jsons)\n[![Code Coverage](https://codecov.io/gh/ramonhagenaars/jsons/branch/master/graph/badge.svg)](https://codecov.io/gh/ramonhagenaars/jsons)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ramonhagenaars/jsons/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ramonhagenaars/jsons/?branch=master)\n\n\n\u003cp align='center'\u003e\n  \u003ca href='https://jsons.readthedocs.io/en/latest/'\u003e\n    \u003cimg width='150' src='https://github.com/ramonhagenaars/jsons/raw/master/resources/jsons-logo.svg?sanitize=true' /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n  - *Turn Python objects into dicts or (json)strings and back*\n  - *No changes required to your objects*\n  - *Easily customizable and extendable*\n  - *Works with dataclasses, attrs and POPOs*\n\n💗 this lib? Leave a ★ and tell your colleagues!\n\nExample of a model to serialize:\n\n```python\n\u003e\u003e\u003e @dataclass\n... class Person:\n...    name: str\n...    birthday: datetime\n...\n\u003e\u003e\u003e p = Person('Guido van Rossum', birthday_guido)\n```\n\nExample of using jsons to serialize:\n\n```python\n\u003e\u003e\u003e out = jsons.dump(p)\n\u003e\u003e\u003e out\n{'birthday': '1956-01-31T12:00:00Z', 'name': 'Guido van Rossum'}\n```\n\nExample of using jsons to deserialize:\n\n```python\n\u003e\u003e\u003e p2 = jsons.load(out, Person)\n\u003e\u003e\u003e p2\nPerson(name='Guido van Rossum', birthday=datetime.datetime(1956, 1, 31, 12, 0, tzinfo=datetime.timezone.utc))\n```\n\n# Installation\n\n    pip install jsons\n\n# Usage\n\n```python\nimport jsons\n\nsome_instance = jsons.load(some_dict, SomeClass)  # Deserialization\nsome_dict = jsons.dump(some_instance)  # Serialization\n```\n\nIn some cases, you have instances that contain other instances that need (de)serialization, for instance with lists or dicts. You can use the\n`typing` classes for this as is demonstrated below.\n\n```python\nfrom typing import List, Tuple\nimport jsons\n\n# For more complex deserialization with generic types, use the typing module\nlist_of_tuples = jsons.load(some_dict, List[Tuple[AClass, AnotherClass]])\n```\n\n(For more examples, see the\n[FAQ](https://jsons.readthedocs.io/en/latest/faq.html))\n\n# Documentation \n\n  - [Main documentation](https://jsons.readthedocs.io/en/latest/)\n  - [API docs](https://jsons.readthedocs.io/en/latest/api.html)\n  - [FAQ](https://jsons.readthedocs.io/en/latest/faq.html)\n\n# Meta\n\n## Recent updates\n\n### 1.6.3\n\n- Bugfix: a string was sometimes unintentionally parsed into a datetime.\n\n### 1.6.2\n\n- Bugfix: `fork_inst`s were not propagated in `default_list_deserializer` (thanks to patrickguenther).\n\n### 1.6.1\n\n- Bugfix: Loading dicts with hashed keys could cause an error due to being loaded twice (thanks to georgeharker).\n- Bugfix: IntEnums were not serialized with their names when `use_enum_name=True` (thanks to georgeharker).\n- Bugfix: Named tuples did not use `typing.get_type_hints` for getting the types, causing trouble in future annotations (thanks to georgeharker).\n\n### 1.6.0\n\n- Feature: Support for Python3.10.\n- Feature: Support for `attrs`.\n\n### 1.5.1\n\n- Bugfix: `ZoneInfo` failed to dump if attached to a `datetime`.\n\n### 1.5.0\n\n- Feature: Support for `ZoneInfo` on Python3.9+.\n- Change: microseconds are no longer stripped by default (thanks to pietrodn).\n\n### 1.4.2\n\n- Bugfix: get_origin did not work with python3.9+ parameterized collections (e.g. `dict[str, str]`).\n\n### 1.4.1\n\n- Bugfix: Types of attributes that are not in the constructor were not properly looked for. See issue #128.\n\n### 1.4.0\n\n- Feature: DefaultDicts can now be deserialized.\n- Feature: Dicts with any (hashable) key can now be dumped and loaded.\n- Feature: Suppress specific warnings.\n- Bugfix: Loading a verbose-serialized object in a list could sometimes deserialize that object as a parent class.\n- Bugfix: Unwanted stringification of NoneValues is now prevented in Optionals and Unions with NoneType.\n- Bugfix: Fixed a bug with postponed annotations and dataclasses. See also [Issue34776](https://bugs.python.org/issue34776).\n- Bugfix: Types of attributes that are not in the constructor are now looked for in __annotations__.\n\n### 1.3.1\n\n- Bugfix: Fixed bug where classmethods were included in the serialized result.\n\n### 1.3.0\n\n- Feature: Added `warn_on_fail` parameter to `default_list_deserializer` that allows to continue deserialization upon errors.\n- Feature: Added `transform` that can transform an object to an object of another type.\n- Feature: Added serializer and deserializer for `pathlib.Path` (thanks to alexmirrington).\n- Change: When loading a list fails, the error message now points to the failing index.\n- Bugfix: Fixed bug when dumping an object with an innerclass. \n\n### 1.2.0\n\n- Bugfix: Fixed bug with postponed typehints (PEP-563).\n- Bugfix: Loading an invalid value targeting an optional did not raise.\n- Bugfix: Loading a dict did not properly pass key_transformers.\n- Bugfix: Loading a namedtuple did not properly use key_transformers.\n- Bugfix: Utilized `__annotations__` in favor `_field_types` because of deprecation as of 3.8.\n\n### 1.1.2\n\n- Feature: Added `__version__` which can be imported from `jsons`\n- Bugfix: Dumping a tuple with ellipsis failed in strict mode.\n\n### 1.1.1\n\n  - Feature: Added a serializer for ``Union`` types.\n  - Change: Exceptions are more clear upon deserialization failure (thanks to haluzpav).\n  - Change: You can no longer announce a class with a custom name.\n  - Bugfix: Fixed dumping optional attributes.\n  - Bugfix: Dataclasses inheriting from ``JsonSerializable`` always dumped their attributes as if in strict mode. \n\n### 1.1.0\n\n  - Feature: Added ``strict`` parameter to ``dump`` to indicate that dumping a certain ``cls`` will ignore any extra data.\n  - Feature: When using ``dump(obj, cls=x)``, ``x`` can now be any class (previously, only a class with ``__slots__``).\n  - Feature: Support for dumping ``Decimal`` (thanks to herdigiorgi).\n  - Feature: Primitives are now cast if possible when dumping (e.g. ``dump(5, str)``).\n  - Feature: Dumping iterables with generic types (e.g. ``dump(obj, List[str])``) will now dump with respect to that types (if ``strict``)\n  - Feature: The ``default_dict`` serializer now optionally accepts types: ``Optional[Dict[str, type]]``.\n  - Change: Improved performance when dumping using ``strict=True`` (up to 4 times faster!).\n  - Bugfix: ``set_validator`` with multiple types did not work.\n\n### 1.0.0\n\n  - Feature: Added a serializer/deserializer for `time`.\n  - Feature: Added a serializer/deserializer for `timezone`.\n  - Feature: Added a serializer/deserializer for `timedelta`.\n  - Feature: Added a serializer/deserializer for `date`.\n  - Bugfix: Dumping verbose did not store the types of dicts (`Dict[K,\n    V]`).\n  - Bugfix: Loading with `List` (no generic type) failed.\n  - Bugfix: Loading with `Dict` (no generic type) failed.\n  - Bugfix: Loading with `Tuple` (no generic type) failed.\n  \n\n## Contributors\n\nSpecial thanks to the following contributors of code, discussions or\nsuggestions:\n\n[patrickguenther](https://github.com/patrickguenther),\n[davetapley](https://github.com/davetapley),\n[pietrodn](https://github.com/pietrodn),\n[georgeharker](https://github.com/georgeharker),\n[aecay](https://github.com/aecay),\n[bibz](https://github.com/bibz),\n[thijss](https://github.com/Thijss),\n[alexmirrington](https://github.com/alexmirrington),\n[tirkarthi](https://github.com/tirkarthi), \n[marksomething](https://github.com/marksomething), \n[herdigiorgi](https://github.com/herdigiorgi), \n[jochembroekhoff](https://github.com/jochembroekhoff), \n[robinklaassen](https://github.com/robinklaassen), \n[ahmetkucuk](https://github.com/ahmetkucuk), \n[casparjespersen](https://github.com/casparjespersen), \n[cypreess](https://github.com/cypreess), \n[gastlich](https://github.com/gastlich), \n[jmolinski](https://github.com/jmolinski), \n[haluzpav](https://github.com/haluzpav), \n[finetuned89](https://github.com/finetuned89)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framonhagenaars%2Fjsons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framonhagenaars%2Fjsons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framonhagenaars%2Fjsons/lists"}