{"id":16061083,"url":"https://github.com/amancevice/flatsplode","last_synced_at":"2025-04-22T22:19:01.124Z","repository":{"id":44856313,"uuid":"157446150","full_name":"amancevice/flatsplode","owner":"amancevice","description":"Flatten/Explode JSON objects","archived":false,"fork":false,"pushed_at":"2024-06-18T16:29:58.000Z","size":149,"stargazers_count":19,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-22T22:18:55.041Z","etag":null,"topics":["json","python"],"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/amancevice.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-11-13T21:01:03.000Z","updated_at":"2025-04-19T16:06:38.000Z","dependencies_parsed_at":"2024-06-18T20:44:39.483Z","dependency_job_id":"fe57e173-df84-46e6-8f89-2f1ffa2aed60","html_url":"https://github.com/amancevice/flatsplode","commit_stats":{"total_commits":93,"total_committers":3,"mean_commits":31.0,"dds":0.5483870967741935,"last_synced_commit":"8797d784b4ed69ce42122631d3065190c771c90e"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amancevice%2Fflatsplode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amancevice%2Fflatsplode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amancevice%2Fflatsplode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amancevice%2Fflatsplode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amancevice","download_url":"https://codeload.github.com/amancevice/flatsplode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250331816,"owners_count":21413104,"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","python"],"created_at":"2024-10-09T04:07:48.028Z","updated_at":"2025-04-22T22:19:01.096Z","avatar_url":"https://github.com/amancevice.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flatsplode\n\n[![pypi](https://img.shields.io/pypi/v/flatsplode?color=yellow\u0026logo=python\u0026logoColor=eee\u0026style=flat-square)](https://pypi.org/project/flatsplode/)\n[![python](https://img.shields.io/pypi/pyversions/flatsplode?logo=python\u0026logoColor=eee\u0026style=flat-square)](https://pypi.org/project/flatsplode/)\n[![pytest](https://img.shields.io/github/actions/workflow/status/amancevice/flatsplode/pytest.yml?logo=github\u0026style=flat-square)](https://github.com/amancevice/flatsplode/actions/workflows/pytest.yml)\n[![coverage](https://img.shields.io/codeclimate/coverage/amancevice/flatsplode?logo=code-climate\u0026style=flat-square)](https://codeclimate.com/github/amancevice/flatsplode/test_coverage)\n[![maintainability](https://img.shields.io/codeclimate/maintainability/amancevice/flatsplode?logo=code-climate\u0026style=flat-square)](https://codeclimate.com/github/amancevice/flatsplode/maintainability)\n\nFlatten/Explode JSON objects.\n\n## Installation\n\n```bash\npip install flatsplode\n```\n\n## Usage\n\nUse the `flatsplode()` function to recursively flatten and explode complex JSON objects.\n\nImport the `flatsplode` function:\n\n```python\nfrom flatsplode import flatsplode\n```\n\nCreate a sample object to flatsplode:\n\n```python\nitem = {\n    'id': '78e5b18c',\n    'keywords': [\n        'fizz',\n        'buzz'\n    ],\n    'attrs': [\n        {'name': 'color', 'value': 'green'},\n        {'name': 'size', 'value': 42},\n    ],\n    'deep': {\n        'nested': {\n            'keys': {\n                'fizz': 'buzz',\n                'jazz': 'fuzz',\n            }\n        }\n    }\n}\n```\n\nCalling `flatsplode(item)` will return a generator. Use `list()` to expand:\n\n```python\nlist(flatsplode(item))\n\n[\n    {\n        'id': '78e5b18c',\n        'keywords': 'fizz',\n        'attrs.name': 'color',\n        'attrs.value': 'green',\n        'deep.nested.keys.fizz': 'buzz',\n        'deep.nested.keys.jazz': 'fuzz'\n    },\n    {\n        'id': '78e5b18c',\n        'keywords': 'fizz',\n        'attrs.name': 'size',\n        'attrs.value': 42,\n        'deep.nested.keys.fizz': 'buzz',\n        'deep.nested.keys.jazz': 'fuzz'\n    },\n    {\n        'id': '78e5b18c',\n        'keywords': 'buzz',\n        'attrs.name': 'color',\n        'attrs.value': 'green',\n        'deep.nested.keys.fizz': 'buzz',\n        'deep.nested.keys.jazz': 'fuzz'\n    },\n    {\n        'id': '78e5b18c',\n        'keywords': 'buzz',\n        'attrs.name': 'size',\n        'attrs.value': 42,\n        'deep.nested.keys.fizz': 'buzz',\n        'deep.nested.keys.jazz': 'fuzz'\n    }\n]\n```\n\nYou can also provide your own join-character:\n\n```python\nlist(flatsplode(item, '/'))\n\n[\n    {\n        'id': '78e5b18c',\n        'keywords': 'fizz',\n        'attrs/name': 'color',\n        'attrs/value': 'green',\n        'deep/nested/keys/fizz': 'buzz',\n        'deep/nested/keys/jazz': 'fuzz'\n    },\n    …\n]\n```\n\nFlatsploding is useful when converting objects to pandas DataFrame matrices:\n\n```python\nimport pandas\nfrom flatsplode import flatsplode\n\npandas.DataFrame(flatsplode(item))\n```\n\nPandas also has a built in normalizer that will flatten (but not explode) your data:\n\n```python\nfrom flatsplode import explode\n\npandas.json_normalize(explode(item))\n```\n\nResult:\n\n```plaintext\n         id attrs.name attrs.value deep.nested.keys.fizz deep.nested.keys.jazz keywords\n0  78e5b18c      color       green                  buzz                  fuzz     fizz\n1  78e5b18c       size          42                  buzz                  fuzz     fizz\n2  78e5b18c      color       green                  buzz                  fuzz     buzz\n3  78e5b18c       size          42                  buzz                  fuzz     buzz\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famancevice%2Fflatsplode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famancevice%2Fflatsplode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famancevice%2Fflatsplode/lists"}