mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00

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
21 lines
436 B
Ruby
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
|