{"id":25808123,"url":"https://github.com/misaghmomenib/json2csv-go","last_synced_at":"2026-05-07T16:03:45.310Z","repository":{"id":279109097,"uuid":"937745609","full_name":"MisaghMomeniB/JSON2CSV-Go","owner":"MisaghMomeniB","description":"A Simple Go Program That Converts a Json File to a Csv File. It Reads a Json Array of Objects, Extracts Keys as Headers, and Writes the Data Into a Csv Format. ","archived":false,"fork":false,"pushed_at":"2025-06-13T14:30:59.000Z","size":11,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-13T15:40:35.380Z","etag":null,"topics":["converter","git","go","golang","json2csv","open-source"],"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/MisaghMomeniB.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-23T19:48:46.000Z","updated_at":"2025-06-13T14:31:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"b1840a5d-9f55-4430-8b69-6c3452ca79a3","html_url":"https://github.com/MisaghMomeniB/JSON2CSV-Go","commit_stats":null,"previous_names":["misaghmomenib/json2csv-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MisaghMomeniB/JSON2CSV-Go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FJSON2CSV-Go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FJSON2CSV-Go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FJSON2CSV-Go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FJSON2CSV-Go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MisaghMomeniB","download_url":"https://codeload.github.com/MisaghMomeniB/JSON2CSV-Go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MisaghMomeniB%2FJSON2CSV-Go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32745138,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["converter","git","go","golang","json2csv","open-source"],"created_at":"2025-02-27T21:58:26.745Z","updated_at":"2026-05-07T16:03:45.305Z","avatar_url":"https://github.com/MisaghMomeniB.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧰 JSON2CSV-Go\n\nA lightweight and efficient **JSON to CSV converter** written in Go. It reads a JSON array of objects, dynamically extracts headers, and writes correct tabular CSV output—ideal for data processing workflows and automation scripts.\n\n---\n\n## 📋 Table of Contents\n\n1. [Overview](#overview)  \n2. [Features](#features)  \n3. [Requirements](#requirements)  \n4. [Installation](#installation)  \n5. [Usage](#usage)  \n6. [Code Structure](#code-structure)  \n7. [Error Handling](#error-handling)  \n8. [Contributing](#contributing)  \n9. [License](#license)\n\n---\n\n## 💡 Overview\n\nThis Go-based CLI tool—complete with reusable package code—automatically:\n\n- Finds the first JSON file in the working directory  \n- Parses it into a slice of Go maps  \n- Extracts dynamic headers from keys  \n- Converts and exports as a `.csv` file  \n- Supports both direct `go run` usage and `go build` for installing the binary :contentReference[oaicite:1]{index=1}\n\n---\n\n## ✅ Features\n\n- 🔍 **Auto-detection**: Identifies the first `.json` file in the directory :contentReference[oaicite:2]{index=2}  \n- 🧩 **Dynamic Headers**: Builds CSV headers based on JSON keys from first entry :contentReference[oaicite:3]{index=3}  \n- 💾 **CSV Export**: Writes a `.csv` file with the same base name as input :contentReference[oaicite:4]{index=4}  \n- 🚫 **Handles Missing Fields**: Missing keys render as empty CSV values :contentReference[oaicite:5]{index=5}  \n- 🚨 **Error Reporting**: Simple messages for missing files or malformed JSON :contentReference[oaicite:6]{index=6}\n\n---\n\n## 🧾 Requirements\n\n- Go **1.18+** (modules enabled)  \n- No external dependencies—uses Go standard `encoding/json` and `encoding/csv`\n\n---\n\n## ⚙️ Installation\n\n### Local build\n```bash\ngit clone https://github.com/MisaghMomeniB/JSON2CSV-Go.git\ncd JSON2CSV-Go/src\ngo build -o json2csv main.go\n````\n\n### Run directly\n\n```bash\ngo run src/main.go\n```\n\n---\n\n## 🚀 Usage\n\nPlace a JSON file (array of objects) in your folder and execute:\n\n```bash\n# e.g. data.json → data.csv\n./json2csv\n```\n\nThe tool reads `*.json`, converts it to CSV, and writes `*.csv`.\n\n---\n\n## 📁 Code Structure\n\n```\nJSON2CSV-Go/\n├── src/\n│   └── main.go         # CLI entrypoint and conversion logic\n├── README.md           # This file\n└── LICENSE             # MIT License\n```\n\n* `main.go`:\n\n  * Finds JSON file via `filepath.Glob(\"*.json\")`\n  * Loads JSON into `[]map[string]interface{}`\n  * Extracts keys from first element\n  * Outputs CSV using `encoding/csv`\n\n---\n\n## ⚠️ Error Handling\n\n* Exits with a message if no JSON files found\n* Reports parsing errors for invalid JSON\n* Gracefully handles write failures\n\n---\n\n## 🤝 Contributing\n\nImprovements welcome! Consider adding:\n\n* Support for nested JSON arrays or pointers\n* CLI flags (e.g., custom file paths, headers)\n* Batch file processing\n\nTo contribute:\n\n1. Fork the repo\n2. Create a feature branch\n3. Submit a PR with clear descriptions\n\n---\n\n## 📄 License\n\nDistributed under the **MIT License**. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisaghmomenib%2Fjson2csv-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisaghmomenib%2Fjson2csv-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisaghmomenib%2Fjson2csv-go/lists"}