linux shell中curl 发送post请求json格式问题

今天在linux中使用curl发送一个post请求时,带有json的数据,在发送时发现json中的变量没有解析出来linux

以下shell

curl -i -X POST -H 'Content-type':'application/json' -d {"BTime":""$btime""} http://api.baidu.com

变量没有作解析json

原来在shell中,"" '仍是有很大区别的,api

把修改后的curl发送贴出app

atime=`date -d "$1" +%s`

btime=`date -d "$2" +%s`

curl -i -X POST -H "'Content-type':'application/json'" -d '{"ATime":"'$atime'","BTime":"'$btime'"}' $url

须要注意的是,json数据里变量要用''括起来
相关文章
相关标签/搜索