linux 中的 curl 命令

curl command in linux

我们如何在 curl 命令中添加 JSON 参数来获取数据? PS:我尝试使用 curl 命令从某些来源获取数据,但它需要在其中传递 JSON 参数。那么我将如何完成呢?

我认为提及内容类型 json 并传递数据会做正确的事情

curl -H "Content-Type: application/json" -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here

以上适用于 GET 方法,适用于 POST 方法

 curl -H "Content-Type: application/json" -X POST -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here