Windows:在命令行上使用 json 数据卷曲
问题描述:
我在 Windows 提示符下运行以下命令:
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"}}}}'
我收到以下错误:
{
"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')
at [Source: org.elasticsearch.common.compress.lzf.LZFCompressedStreamInput@45
4ed1d2; line: 1, column: 2]]; ",
"status" : 400
}
我搜索了解决方案并找到了替代方案,例如将 json 数据放入文件中,但由于某些原因我无法使用它.
I searched for solutions and found alternatives such as put json data in files, but I cannot use it for some reasons.
谢谢!
答
Windows 的 cmd
不支持带单引号的字符串.使用 "
并用 "
转义内部的.
Windows's cmd
doesn't support strings with single quotes. Use "
and escape the inner ones with "
.