{"id":15905946,"url":"https://github.com/lucacappelletti94/deflate_dict","last_synced_at":"2025-06-27T02:36:28.883Z","repository":{"id":89744578,"uuid":"188645236","full_name":"LucaCappelletti94/deflate_dict","owner":"LucaCappelletti94","description":"Python package to deflate and re-inflate dictionaries.","archived":false,"fork":false,"pushed_at":"2024-10-26T16:36:27.000Z","size":133,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-02T19:18:43.784Z","etag":null,"topics":[],"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/LucaCappelletti94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":"LucaCappelletti94"}},"created_at":"2019-05-26T05:48:20.000Z","updated_at":"2024-10-26T16:36:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"3b38b8d0-4c4a-412b-8b80-9be2198c61cd","html_url":"https://github.com/LucaCappelletti94/deflate_dict","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/LucaCappelletti94/deflate_dict","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fdeflate_dict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fdeflate_dict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fdeflate_dict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fdeflate_dict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucaCappelletti94","download_url":"https://codeload.github.com/LucaCappelletti94/deflate_dict/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fdeflate_dict/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262179106,"owners_count":23271169,"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":[],"created_at":"2024-10-06T13:20:19.438Z","updated_at":"2025-06-27T02:36:28.852Z","avatar_url":"https://github.com/LucaCappelletti94.png","language":"Python","readme":"# 🎈🌵 Deflate Dict\n\n[![pip](https://badge.fury.io/py/deflate-dict.svg)](https://pypi.org/project/deflate-dict/)\n[![python](https://img.shields.io/pypi/pyversions/deflate-dict)](https://pypi.org/project/deflate-dict/)\n[![license](https://img.shields.io/pypi/l/deflate-dict)](https://pypi.org/project/deflate-dict/)\n[![downloads](https://pepy.tech/badge/deflate-dict)](https://pepy.tech/project/deflate-dict)\n[![mypy](https://github.com/LucaCappelletti94/deflate_dict/actions/workflows/mypy.yml/badge.svg)](https://github.com/LucaCappelletti94/deflate_dict/actions/)\n[![Github Actions](https://github.com/LucaCappelletti94/deflate_dict/actions/workflows/python.yml/badge.svg)](https://github.com/LucaCappelletti94/deflate_dict/actions/)\n\nPython package to deflate 🌵 and re-inflate 🎈 nested dictionaries.\n\n## How do I install this package?\n\nAs usual, just download it using pip:\n\n```shell\npip install deflate_dict\n```\n\n## Deflating a dictionary\n\nA dictionary will be deflated down to its smallest non-further iterable elements, defined as those not containing lists or dictionaries.\n\n```python\nfrom deflate_dict import deflate\nD = {\n    \"a\": [\n        {\n            \"b\": (0, 1, 2)\n        },\n        {\n            \"c\": [1, 2, 3]\n        }\n    ]\n}\nresult = deflate(D, sep=\"_\")\n\n# {'str(a)_listIndex(0)_str(b)': (0, 1, 2), 'str(a)_listIndex(1)_str(c)': [1, 2, 3]}\n```\n\n## Inflate a dictionary\n\nTo reinflate a dictionary to its forgotten glory, just go with:\n\n```python\nfrom deflate_dict import inflate\nD = {\"a_0_b\": (0, 1, 2), \"a_1_c\": [1, 2, 3], \"d\": 4}\n\nresult = inflate(D, sep=\"_\")\n\n# {'a': [{'b': (0, 1, 2)}, {'c': [1, 2, 3]}], 'd': 4}\n```\n\n## Handling and restoring mixed types\n\nTo deflate and re-inflate mixed types and restore them to the original type you can use the `type_encode_key` keyword:\n\n```python\nfrom deflate_dict import deflate\n\nD = {\n    \"a\":[\n        {\n            \"b\":(0,1,2)\n        },\n        {\n            \"c\": [1,2,3]\n        }\n    ]\n}\n\nprint(deflate(D, sep=\"_\", type_encode_key=False))\n\n# {\n# 'a_listIndex(0)_b': (0, 1, 2),\n# 'a_listIndex(1)_c': [1, 2, 3]\n# }\n\nprint(deflate(D, sep=\"_\", type_encode_key=True))\n\n# {\n#    'str(a)_listIndex(0)_str(b)': (0, 1, 2),\n#    'str(a)_listIndex(1)_str(c)': [1, 2, 3]\n# }\n```\n\n## License\n\nThis software is distributed under MIT license.\n","funding_links":["https://github.com/sponsors/LucaCappelletti94"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucacappelletti94%2Fdeflate_dict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucacappelletti94%2Fdeflate_dict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucacappelletti94%2Fdeflate_dict/lists"}