C/C++编程:[globbing] unmatched close brace/bracket in column 6

根据官方教程,在命令行中使用curl执行下面命令:

curl -d '[{"firstname": "barack", "lastname": "obama"}, {"firstname": "mitt", "lastname": "romney"}]' -H 'Content-Type: application/json'  http://127.0.0.1:5000/people

出现了如下错误:

curl: (6) Could not resolve host: barack,
curl: (6) Could not resolve host: lastname
curl: (3) [globbing] unmatched close brace/bracket in column 6
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: mitt,
curl: (6) Could not resolve host: lastname
curl: (3) [globbing] unmatched close brace/bracket in column 7
curl: (6) Could not resolve host: application
{
    
    "_status": "ERR", "_issues": {
    
    "'[{firstname:": "unknown field", "lastname": "required field"}, "_error": {
    
    "code": 422, "message": "Insertion failure: 1 document(s) contain(s) error(s)"}}

原因是由于我使用的是windows系统,而window的command.exe似乎不支持单引号,所以只要将其中的单引号改为双引号,并转义字符串中的任何双引号

curl -d "[{\"firstname\": \"barack\", \"lastname\": \"obama\"}, {\"firstname\": \"mitt\", \"lastname\": \"romney\"}]" -H "Content-Type: application/json" http://127.0.0.1:5000/people

猜你喜欢

转载自blog.csdn.net/zhizhengguan/article/details/121790409