Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/birchb1024/json2csv
Convert JSON data to CSV data easily
https://github.com/birchb1024/json2csv
Last synced: about 2 months ago
JSON representation
Convert JSON data to CSV data easily
- Host: GitHub
- URL: https://github.com/birchb1024/json2csv
- Owner: birchb1024
- Created: 2022-08-05T02:26:45.000Z (over 2 years ago)
- Default Branch: trunk
- Last Pushed: 2022-08-11T02:24:03.000Z (over 2 years ago)
- Last Synced: 2024-06-19T18:04:00.434Z (6 months ago)
- Language: Go
- Size: 2.07 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# json2csv
Convert JSON data to CSV data easily
# Usage
`json2csv` is a simple filter reading from standard input and sending to standard output.
```
$ json2csv outputfile
```
Usage of json2csv:`-dedupe`
Remove duplicate rows. Usage: -dedupe=false (default true)`-index` string
List index column name part. (default "#")`-list` string
List column name part. (default "LIST")`-separator` string
column name internal separator. (default ".")# Description
`json2csv` works for JSON files which are already organized into simple record structures.
```JSON
[
{ "Title": "The Life of Brian",
"date": { "year": "1908", "month": "January"},
"cast" : [ "Joanna Lumley", "Terrance Trent Darby" ]
},
{ "Title": "The Life of Pi",
"date": { "year": "2012", "month": "January"},
"cast" : ["Suraj Sharma", "Nota Tiger" ]
}
]
```The map keys are expected to become column names (not values), the map values are
mapped to cells. Nested maps result in compound column names. Embedded lists have a
row per each item in the list. The above is output as:```
LIST,LIST.#,LIST.Title,LIST.date.year,LIST.cast.LIST,LIST.date.month,LIST.cast.LIST.#
,1,The Life of Brian,1908,Joanna Lumley,January,1
,1,The Life of Brian,1908,Terrance Trent Darby,January,2
,2,The Life of Pi,2012,Suraj Sharma,January,1
,2,The Life of Pi,2012,Nota Tiger,January,2
```Here's the pretty version:
|LIST|LIST.#|LIST.Title |LIST.date.year|LIST.cast.LIST |LIST.date.month|LIST.cast.LIST.#|
|----|------|-----------------|--------------|--------------------|---------------|----------------|
| |1 |The Life of Brian|1908 |Joanna Lumley |January |1 |
| |1 |The Life of Brian|1908 |Terrance Trent Darby|January |2 |
| |2 |The Life of Pi |2012 |Suraj Sharma |January |1 |
| |2 |The Life of Pi |2012 |Nota Tiger |January |2 |# Column names
The column names format can be altered to avoid issues by using the command-line options.
Example:
```
$ ./json2csv -list 'items' -index number -separator '_'