summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb
diff options
context:
space:
mode:
Diffstat (limited to 'jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb')
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb b/jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb
new file mode 100644
index 0000000..0127ac8
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb
@@ -0,0 +1,24 @@
+require 'psych/json/ruby_events'
+
+module Psych
+ module Visitors
+ class JSONTree < YAMLTree
+ include Psych::JSON::RubyEvents
+
+ def self.create options = {}
+ emitter = Psych::JSON::TreeBuilder.new
+ class_loader = ClassLoader.new
+ ss = ScalarScanner.new class_loader
+ new(emitter, ss, options)
+ 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