<分区>
我有以下输入,我正在尝试获取关键详细信息并尝试形成以下 json 文件,但是当我尝试运行以下命令时,它返回了语法错误,我不确定如何解决这个
输入(Response.Json):
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 4,
"issues": [{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "1999875",
"self": "https://amazon.kindle.com/jira/rest/api/2/issue/1999875",
"key": "KINDLEAMZ-67578"
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "2019428",
"self": "https://amazon.kindle.com/jira/rest/api/2/issue/2019428",
"key": "KINDLEAMZ-68661"
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "2010958",
"self": "https://amazon.kindle.com/jira/rest/api/2/issue/2010958",
"key": "KINDLEAMZ-68167"
}
]
}
命令:
> getResponse=$( jq 'reduce (.issues | to_entries[]) as {$key,$value}
> ({}; .["JIRA-\($key + 1)"] = $value.key )' response.json );
错误:
error: syntax error, unexpected '{', expecting '$' reduce (.issues | to_entries[]) as {$key,$value} ({}; .["JIRA-($key + 1)"] = $value.key ) ^ 1 compile error
预期输出:
{
"JIRA-1":"KINDLEAMZ-67578",
"JIRA-2":"KINDLEAMZ-68661",
"JIRA-3":"KINDLEAMZ-68167"
}
任何人请帮助我解决这个问题。我完全被封锁了,毫 headless 绪......