{"id":32308036,"url":"https://github.com/danilofuchs/flat","last_synced_at":"2026-02-24T14:37:55.464Z","repository":{"id":46031217,"uuid":"242021532","full_name":"danilofuchs/flat","owner":"danilofuchs","description":"Take a nested Map and flatten it with delimited keys","archived":false,"fork":false,"pushed_at":"2023-11-07T17:01:25.000Z","size":20,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-12-08T01:00:50.056Z","etag":null,"topics":["dart","flat","pubdev"],"latest_commit_sha":null,"homepage":null,"language":"Dart","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/danilofuchs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-02-21T00:35:40.000Z","updated_at":"2023-11-08T10:42:01.000Z","dependencies_parsed_at":"2022-09-13T08:31:50.641Z","dependency_job_id":null,"html_url":"https://github.com/danilofuchs/flat","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"purl":"pkg:github/danilofuchs/flat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilofuchs%2Fflat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilofuchs%2Fflat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilofuchs%2Fflat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilofuchs%2Fflat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danilofuchs","download_url":"https://codeload.github.com/danilofuchs/flat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danilofuchs%2Fflat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29785799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T10:45:18.109Z","status":"ssl_error","status_checked_at":"2026-02-24T10:45:09.911Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dart","flat","pubdev"],"created_at":"2025-10-23T07:26:22.155Z","updated_at":"2026-02-24T14:37:55.459Z","avatar_url":"https://github.com/danilofuchs.png","language":"Dart","readme":"# flat\n\nTake a nested Map and flatten it with delimited keys. Entirely based on node.js [flat](https://www.npmjs.com/package/flat).\n\n\u003e It does not achieve feature parity yet, as some options are missing from `flatten` (transformKey) and `unflatten` (`object`, `overwrite`, `transformKey`).\n\n\u003e Currently, it bails out of a tree if it finds something different than a `Map` or `List` when flatening, or a nested `Map` or `List` when unflattening.\n\n## Methods\n\n### `flatten`\n\n```dart\nimport 'package:flat/flat.dart';\n\nflatten(\n    {\n      \"a\": 1,\n      \"list1\": [\"item1\", \"item2\"],\n      \"f\": {\n        \"list2\": [\"item3\", \"item4\", \"item5\"],\n        \"g\": 2,\n        \"h\": true,\n        \"j\": \"text\",\n      },\n    },\n  );\n\n// {\n//   \"a\": 1,\n//   \"list1.0\": \"item1\",\n//   \"list1.1\": \"item2\",\n//   \"f.list2.0\": \"item3\",\n//   \"f.list2.1\": \"item4\",\n//   \"f.list2.2\": \"item5\",\n//   \"f.g\": 2,\n//   \"f.h\": true,\n//   \"f.j\": \"text\"\n// }\n```\n\n#### `delimiter`\n\nUse a custom delimiter for flattening your objects, instead of `.`\n\n#### `safe`\n\nWhen enabled, flat will preserve arrays and their contents. This is disabled by default.\n\n```dart\nimport 'package:flat/flat.dart';\n\nflatten({\n  'this': [\n    {'contains': 'arrays'},\n    {\n      'preserving': {'them': 'for you'}\n    }\n  ]\n}, safe: true);\n\n// {\n//   'this': [\n//     {'contains': 'arrays'},\n//     {\n//       'preserving': {'them': 'for you'}\n//     }\n//   ]\n// };\n```\n\n#### `maxDepth`\n\nMaximum number of nested objects to flatten.\n\n```dart\nimport 'package:flat/flat.dart';\n\nflatten({\n  'key1': {'keyA': 'valueI'},\n  'key2': {'keyB': 'valueII'},\n  'key3': {\n    'a': {\n      'b': {'c': 2}\n    }\n  }\n}, maxDepth: 2);\n\n// {\n//   'key1.keyA': 'valueI',\n//   'key2.keyB': 'valueII',\n//   'key3.a': {\n//     'b': {'c': 2}\n//   }\n// };\n```\n\n### `unflatten`\n\nReverse process from `flatten`.\n\n\u003e Only supports completely flat maps as input.\n\n```dart\nunflatten({\n  \"a\": 1,\n  \"list1.0\": \"item1\",\n  \"list1.1\": \"item2\",\n  \"f.list2.0\": \"item3\",\n  \"f.list2.1\": \"item4\",\n  \"f.list2.2\": \"item5\",\n  \"f.g\": 2,\n  \"f.h\": true,\n  \"f.j\": \"text\"\n});\n\n// {\n//   \"a\": 1,\n//   \"list1\": [\"item1\", \"item2\"],\n//   \"f\": {\n//     \"list2\": [\"item3\", \"item4\", \"item5\"],\n//     \"g\": 2,\n//     \"h\": true,\n//     \"j\": \"text\",\n//   },\n// }\n```\n\n#### `delimiter`\n\nUse a custom delimiter for unflattening your objects, instead of `.`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanilofuchs%2Fflat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanilofuchs%2Fflat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanilofuchs%2Fflat/lists"}