summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/visitors/json_tree.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-20 00:20:57 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-20 00:20:57 +0000
commit74b0a7a06f62216d46ccb1ae53b2c52121622809 (patch)
tree4522f3d19de9c026cb6390795ba92cab2ebf24d3 /ext/psych/lib/psych/visitors/json_tree.rb
parenta17cdfdde29faa7e6c5feb1c31d41e4f42328daa (diff)
* ext/psych/lib/psych/visitors/json_tree.rb: Fix JSON emit for
DateTime and Time classes. * test/psych/test_json_tree.rb: test for JSON emit git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych/visitors/json_tree.rb')
-rw-r--r--ext/psych/lib/psych/visitors/json_tree.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/psych/lib/psych/visitors/json_tree.rb b/ext/psych/lib/psych/visitors/json_tree.rb
index f2dbfb33d7..dd06e80607 100644
--- a/ext/psych/lib/psych/visitors/json_tree.rb
+++ b/ext/psych/lib/psych/visitors/json_tree.rb
@@ -5,6 +5,15 @@ module Psych
super
end
+ def visit_Time o
+ formatted = format_time o
+ @emitter.scalar formatted, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
+ end
+
+ def visit_DateTime o
+ visit_Time o.to_time
+ end
+
def visit_String o
@emitter.scalar o.to_s, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
end