在Windows中卷曲-如何在JSON中放置空格? [英] curl in windows - how do i put a space in the json?
本文介绍了在Windows中卷曲-如何在JSON中放置空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有这个curl请求(在Windows cmd提示符下运行):
so i have this curl request (running on a windows cmd prompt):
curl --insecure -g -X POST -H "Content-Type: application/json" -d {\"from\":\"someName\",\"message\":\"this is a message\"} https://some/website/here
运行此命令时,出现错误:
When i run this, i get an error:
curl: (6) Could not resolve host: is; Host not found
curl: (6) Could not resolve host: a; Host not found
curl: (6) Could not resolve host: message; Host not found
这似乎是因为json杂乱无章-空格无法正常工作!
Which seems to be because the json is munged up - the spaces are not working!
如果我想在消息中加空格,我将如何发送此消息?
How would i send this message, if i wanted spaces to be in the, uh, message?
推荐答案
使用双引号"并在URL中使用%20
Use double quotes " and use %20 in url
现在就在Windows命令提示符下尝试一下.您在DATA部分缺少转义符
Just tried on my windows command prompt now. You were missing escape on the DATA part
您的代码
curl --insecure -g -X POST -H "Content-Type: application/json" -d {\"from\":\"someName\",\"message\":\"this is a message\"} https://some/website/here
应该这样逃脱
curl --insecure -g -X POST -H "Content-Type: application/json" -d "{\"from\":\"someName\",\"message\":\"this is a message\"}" https://some/website/here
这篇关于在Windows中卷曲-如何在JSON中放置空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文