【发布时间】:2018-09-01 07:19:58
【问题描述】:
我的backup.json 看起来像这样:
{
"andres": [
[
{
"id": 1,
"email": "password",
"username": test1,
"password": "email@email.com",
"name": "Dummy Account",
"address": "123 st road",,
"ip_address": "0.0.0.0",
"phone": "123-123-1234",
},
{
"id": 2,
"email": "email2@email.com",
"username": test2,
"password": "password",
"name": "Dummy Account",
"address": "123 st road",,
"ip_address": "0.0.0.0",
"phone": "123-123-1234"
}
],
]
}
我正在使用命令:
jq -r '.andres[] | .id, .email, .username, .password, .name, .address, .ip_address, .phone' < backup.json > backup.csv
但它给出了错误:
Cannot index array with string "id"
我希望它看起来像这样:
1,email@email.com,test1,password,Dummy Account,123 st road,0.0.0.0,123-123-1234
2,email@email.com,test2,password,Dummy Account,123 st road,0.0.0.0,123-123-1234
我是使用 JQ 的新手。有人可以修复我的命令并告诉我哪里出错了吗?
谢谢!
【问题讨论】: