1
我有一个包含JSON如下在壳变量转换JSON字符串字符串文字
{ “测试”: “测试”, “温度”: “温度” } shell变量
这是JSON的一部分,我得到了来自JQ,这是一个JSON解析器tool.But当我通过这个卷曲的POST请求体的一部分解析时,它被越来越转化为
'{'
'"test"' ':' 'test,'
'"temp"' ':' 'temp'
'}'
但我想要它作为
'{
"test" : "test",
"temp" : "temp"
}'
VAL=$(echo "$RET" | jq ".pending[$j].value")
VAL是将包含JSON 可变我需要通过这个VAL作为请求体卷曲
curl -X POST -H "$CONTENT_HEADER" -H "$AUTH_HEADER" http://localhost:8080/testApi -d $VAL
小心发布您的bash代码? –
请查看[editing-help](http://stackoverflow.com/editing-help)。 – Cyrus
你见过这篇文章http://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest – vvs