{"id":16265551,"url":"https://github.com/bruth/flatjson","last_synced_at":"2025-10-09T17:36:22.480Z","repository":{"id":141233266,"uuid":"41553458","full_name":"bruth/flatjson","owner":"bruth","description":"Flatten nested JSON documents.","archived":false,"fork":false,"pushed_at":"2015-08-28T15:08:56.000Z","size":128,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T10:56:04.761Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bruth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-28T15:04:22.000Z","updated_at":"2023-03-03T14:54:15.000Z","dependencies_parsed_at":"2023-03-13T05:16:02.533Z","dependency_job_id":null,"html_url":"https://github.com/bruth/flatjson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fflatjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fflatjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fflatjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruth%2Fflatjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bruth","download_url":"https://codeload.github.com/bruth/flatjson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247862053,"owners_count":21008617,"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-10T17:09:37.699Z","updated_at":"2025-10-09T17:36:17.446Z","avatar_url":"https://github.com/bruth.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flatjson\n\n[![GoDoc](https://godoc.org/github.com/bruth/flatjson?status.svg)](https://godoc.org/github.com/bruth/flatjson)\n\nThe `flatjson` package provides an encoder to take a value or existing JSON string and convert it into a flat map or array or key-value pairs. For example, the following document can be flattened to an array of key-value pairs:\n\n```json\n{\n    \"name\": \"Bob Smith\",\n    \"address\": {\n        \"street\": \"123 Main Street\",\n        \"city\": \"Boresville\",\n        \"zipcode\": 13943\n    },\n    \"hobbies\": [\"tennis\", \"coding\", \"cooking\"]\n}\n```\n\n```json\n[\n    [\"name\", \"Bob Smith\"],\n    [\"address.street\", \"123 Main Street\"],\n    [\"address.city\", \"Boresville\"],\n    [\"address.zipcode\", 13943],\n    [\"hobbies[0]\", \"tennis\"],\n    [\"hobbies[1]\", \"coding\"],\n    [\"hobbies[2]\", \"cooking\"]\n]\n```\n\n## What is the motivation?\n\nWorking with a flat set of a key value pairs is often easier to work with when storing or indexing nested documents. It also makes it easier to compare documents by just iterating over the keys and comparing values rather than recursing into documents or arrays.\n\n## Install\n\nGet the library.\n\n```\ngo get github.com/bruth/flatjson\n```\n\nInstall the command line tool.\n\n```\ngo install github.com/bruth/flatjson/cmd/flatjson\n```\n\n## Library Example\n\nConvert existing JSON into flat format.\n\n```go\nimport (\n    \"strings\"\n\n    \"github.com/bruth/flatjson\"\n)\n\nvar json = `\n{\n    \"name\": \"Bob Smith\",\n    \"address\": {\n        \"street\": \"123 Main Street\",\n        \"city\": \"Boresville\",\n        \"zipcode\": 13943\n    },\n    \"hobbies\": [\"tennis\", \"coding\", \"cooking\"]\n}\n`\n\nr := strings.NewReader(json)\n\n// Write the JSON to standard out.\nif err := flatjson.NewEncoder(os.Stdout).ConvertMap(r); err != nil {\n    // Handle error..\n}\n```\n\n## CLI Tool\n\n```\nflatjson [-array] [file]\n```\n\n### Example\n\n```\nflatjson\n{\n    \"name\": \"Bob Smith\",\n    \"address\": {\n        \"street\": \"123 Main Street\",\n        \"city\": \"Boresville\",\n        \"zipcode\": 13943\n    },\n    \"hobbies\": [\"tennis\", \"coding\", \"cooking\"]\n}\n{\n    \"address.street\": \"123 Main Street\",\n    \"address.city\": \"Boresville\",\n    \"address.zipcode\": 13943,\n    \"hobbies[0]\": \"tennis\",\n    \"hobbies[1]\": \"coding\",\n    \"hobbies[2]\": \"cooking\",\n    \"name\": \"Bob Smith\"\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruth%2Fflatjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruth%2Fflatjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruth%2Fflatjson/lists"}