此问题已在此处有答案:
Escaping characters in bash (for JSON)(13个回答)
Parsing JSON with Unix tools(46个答案)
4个月前关闭。
我有下面的GET CURL,从中我得到一个xml。
curl -X 'GET' \
'http://local/something/something2' \
-H 'accept: application/json' \
-H 'authorization: auth'
现在我想在这个POST CURL中使用上面收到的xml:
curl -X 'POST' \
'http://something/something2' \
-H 'accept: application/json' \
-H 'authorization: auth' \
-H 'Content-Type: application/json' \
-d '{
"components": [
{
"locator": "sample",
"config": xml file from above
}
]
}'
如何使用POST发出第二个CURL?
1条答案
按热度按时间pdtvr36n1#
请参阅this post,了解如何将第一个命令的输出捕获到变量中。这样使用:
注意双引号-双引号必须在那里,这样
$output
变量才能使用。因此,JSON中的双引号需要转义。