post a json object with an array using curl
来源:互联网 发布:网络信息安全责任状 编辑:程序博客网 时间:2024/05/07 03:45
在测试API时,为了排除session等的干扰,使用curl是一个不错的选择,那么如何使用curl向API传递JSON对象或数组呢?
以下的代码便可实现:
curl -v -X POST \ -H "content-type:application/json" \ "http://URL/api/1/testApi" \ -d '{"tags":["tag1","tag2"],"question":"Which band?","answers":[{"id":"a0","answer":"Answer1"},{"id":"a1","answer":"answer2"}]}'
服务器端的接受:
app.post('/api/1/testApi',function(req,res){console.log(req.body.question);console.log(req.body.tags);var tags = req.body.tags;console.log(tags[0]);var answers = req.body.answers;console.log(answers[0]);var answer0 = answers[0];console.log(answer0.id);});
very good!
0 0
- post a json object with an array using curl
- curl with post json
- jquery ajax post json data(int,string,array,object(own an array property member) to SpringMVC Server
- setting an array element with a sequence
- Using curl to upload POST data with files
- Creating an array of floats using new-object
- CareerCup Rearrange an array using swap with 0
- How to post JSON to PHP with curl
- Using an NSAnimation Object
- Generate a Binary Sort Tree using an array
- CURL POST json字符串
- curl post json
- curl命令Post Json
- javascript: Jquery each loop with json array or object
- javascript: Jquery each loop with json array or object
- Algorithm: Reverse a Integer to an array with recursion
- __curl_rule_01__ declared as an array with a negative size
- '__curl_rule_01__'declared as an array with a negative size
- Python IDE:PyCharm中的那些实用功能
- UICollectionView
- 字符串分割(C++)
- 苹果IOS开发者账号总结
- Tutorial: Installing Multi-Touch Vista
- post a json object with an array using curl
- appium小试用
- 线程安全
- Mysql字符集设置
- js 原型(prototype)继承相关2
- java中利用jsch执行远程命令,实现sftp
- 如何开发一个流畅的云计算架构?
- php中mysql操作的buffer知识
- maven管理SpringMVC+Mybatis无法加载resource资源文件解决办法