Windows:curl与json数据在命令行 [英] Windows: curl with json data on the command line

查看:1603
本文介绍了Windows:curl与json数据在命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows提示中运行以下命令:

  curl -XPUT http://127.0.0.1:9200/测试索引/测试类型/ _mapping?pretty = true -d'{test-type:{properties:{name:{index:analyze,term_vector:with_positions_offsets boost:1.0,store:yes,type:string}}}}'



我得到以下错误:

  {
error:ElasticsearchParseException [内容映射];嵌套:JsonParseException [意外字符('''(代码39)):期望a
有效值(number,String,array,object,'true','false'or'null' \\\
at [Source:org.elasticsearch.common.compress.lzf.LZFCompressedStreamInput@45
4ed1d2; line:1,column:2]];,
status:400
}

我搜索解决方案并找到替代方法,例如将json数据放入文件,它由于某些原因。



谢谢!

解决方案

Windows的 cmd 不支持带单引号的字符串。使用并使用 \转义内部的。


I am running the following command in Windows prompt:

curl -XPUT http://127.0.0.1:9200/test-index/test-type/_mapping?pretty=true -d '{"test-type": {"properties": {"name": {"index": "analyzed", "term_vector": "with_positions_offsets", "boost": 1.0, "store": "yes", "type": "string"}}}}'

I get the following error:

{
  "error" : "ElasticsearchParseException[Failed to parse content to map]; nested: JsonParseException[Unexpected character (''' (code 39)): expected a
valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.common.compress.lzf.LZFCompressedStreamInput@45
4ed1d2; line: 1, column: 2]]; ",
  "status" : 400
}

I searched for solutions and found alternatives such as put json data in files, but I cannot use it for some reasons.

Thanks!

解决方案

Windows's cmd doesn't support strings with single quotes. Use " and escape the inner ones with \".

这篇关于Windows:curl与json数据在命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆