1

I have the below json file:

{
"data": [
    {
        "displayName": "First Name",
        "rank": 1,
        "value": "VALUE"
    },
    {
        "displayName": "Last Name",
        "rank": 2,
        "value": "VALUE"
    },
    {
        "displayName": "Position",
        "rank": 3,
        "value": "VALUE"
    },
    {
        "displayName": "Company Name",
        "rank": 4,
        "value": "VALUE"
    },
    {
        "displayName": "Country",
        "rank": 5,
        "value": "VALUE"
    },
]
}

I would like to have a CSV file in this format:

First Name, Last Name, Position, Company Name, Country

VALUE, VALUE, VALUE, VALUE, VALUE, VALUE

Is this possible by using only jq? I don't have any programming and/or great command-line skills.

4

1 回答 1

1

是的:

.data | sort_by(.rank) | map(.displayName), map(.value) | @csv
于 2014-10-24T03:40:22.103 回答