ruby post json

Posted FireC@t @ Perl6

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby post json相关的知识,希望对你有一定的参考价值。

require net/http
require json
uri = URI(http://localhost/test1.php)
req = Net::HTTP::Post.new uri
content = {name:root,password:password}
req.body = content.to_json
http = Net::HTTP.start(uri.hostname,uri.port)
puts req.body
puts http.request(req).body

 

以上是关于ruby post json的主要内容,如果未能解决你的问题,请参考以下文章