This blog has migrated to blog.bekenev.net.
New posts will not be published here and will appear on the new site instead.

Bash Json Csv

JSON to CSV with BASH

Hey, recently I’ve posted about jq and today I’m going to explain how I used it to parse JSON from web (retrieved with CURL) and turn it to CSV.

First of all let’s see what JSON we have:

{
  "data": [
    {
      "short_data": {
        "name": "value1",
        "link": "value2"
      },
      "long_data": {
        "company_name" "value3",
        "company_position" "value4"
      }
    },
    {/*...*/},
    {/*...*/},
    {/*...*/}
  ]
}

Ok, the CSV we want to get is: