简体   繁体   English

如何读取通过curl命令传递的json文件

[英]How to read json file passed through curl command

curl -H "Content-Type: application/json" -X POST --data "@data.json"  http://localhost:3000/

curl can be used to send multiple types of content but the default of all being the application/x-www-form-urlencoded. curl 可用于发送多种类型的内容,但所有内容的默认值都是 application/x-www-form-urlencoded。 If you need to send a file through the same , you need to put that in the header, and for putting a file you need to specify -d param for the same.如果您需要通过相同的 发送文件,则需要将其放在标题中,而对于放置文件,您需要为其指定 -d 参数。

a sample use of the same can be as :相同的示例使用可以是:

 $ curl -vX POST http://<servername>/<api>/v1/<jsonfilename.json> -d @<file.json> \
--header "Content-Type: application/json"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM