1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/psych/lib/psych/visitors/json_tree.rb
tenderlove 4ed82ae5cb * ext/psych/lib/psych/streaming.rb: refactor streaming methods to a
module.
* ext/psych/lib/psych/stream.rb: extracted streaming specific methods
  to a module.
* ext/psych/lib/psych/json/stream.rb: JSON stream inherits from
  JSONTree and includes streaming methods.
* ext/psych/lib/psych/visitors/json_tree.rb: JSON does not support
  object references, so remove object reference testing when building
  JSON trees.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-21 18:09:38 +00:00

21 lines
436 B
Ruby

require 'psych/json/ruby_events'
module Psych
module Visitors
class JSONTree < YAMLTree
include Psych::JSON::RubyEvents
def initialize options = {}, emitter = Psych::JSON::TreeBuilder.new
super
end
def accept target
if target.respond_to?(:encode_with)
dump_coder target
else
send(@dispatch_cache[target.class], target)
end
end
end
end
end