* ext/json: merge JSON 1.7.5.

fix tests and other fixes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-12-12 10:51:49 +00:00
parent 395d7bb346
commit 43f6fdfb42
12 changed files with 84 additions and 32 deletions

View file

@ -20,10 +20,13 @@ class Time
# Returns a hash, that will be turned into a JSON object and represent this
# object.
def as_json(*)
nanoseconds = [ tv_usec * 1000 ]
respond_to?(:tv_nsec) and nanoseconds << tv_nsec
nanoseconds = nanoseconds.max
{
JSON.create_id => self.class.name,
's' => tv_sec,
'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
'n' => nanoseconds,
}
end