提交 6da5f6b4 编写于 作者: G Godfrey Chan 提交者: GitHub

Merge pull request #25350 from tricknotes/uri-generic-as-json

Define `URI::Generic#as_json`
# Hack to load json gem first so we can overwrite its to_json.
require 'json'
require 'bigdecimal'
require 'uri/generic'
require 'active_support/core_ext/big_decimal/conversions' # for #to_s
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/hash/slice'
......@@ -192,6 +193,12 @@ def as_json(options = nil) #:nodoc:
end
end
class URI::Generic #:nodoc:
def as_json(options = nil)
to_s
end
end
class Process::Status #:nodoc:
def as_json(options = nil)
{ :exitstatus => exitstatus, :pid => pid }
......
......@@ -76,6 +76,8 @@ module EncodingTestCases
RegexpTests = [[ /^a/, '"(?-mix:^a)"' ], [/^\w{1,2}[a-z]+/ix, '"(?ix-m:^\\\\w{1,2}[a-z]+)"']]
URITests = [[ URI.parse('http://example.com'), %("http://example.com") ]]
DateTests = [[ Date.new(2005,2,1), %("2005/02/01") ]]
TimeTests = [[ Time.utc(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +0000") ]]
DateTimeTests = [[ DateTime.civil(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +0000") ]]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册