我有一個捲曲調用查詢JIRA REST API,並返回一個JSON字符串,像下面的(預計在一行):使用SED找引號內,並跳過轉義的引號
{
"expand":"renderedFields,names,schema,transitions,operations,editmeta,changelog",
"id":"36112","self":"https://jira.company.com/rest/api/2/issue/36112",
"key":"FOO-1218",
"fields":
{"summary":"the \"special\" field is not returning what is expected"}
}
我試着使用這個sed腳本解析出「摘要」字段:
sed 's/^.*summary":"\([^"]*\)".*$/\1/'
工作正常,如果「摘要」沒有一個逃脫\」裏面它 - 但當然,與逃脫報價均爲我從示例中得到的是:
the \
我所需的輸出要麼是:
the \"special\" field is not returning what is expected
甚至更多fancily這樣的:
the "special" field is not returning what is expected
它不會出現,我可以在SED做了回顧後,有一個簡單的在bash腳本中解決這個問題的方法?
你爲什麼不使用正確的JSON解析器解析JSON – tripleee
@Jordan什麼是你嗎? r預期產出? –