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

 

posted on 2017-09-16 03:04  Perl6  阅读(221)  评论(0编辑  收藏  举报

导航