Class: Psych::Visitors::JSONTree

Inherits:
YAMLTree show all
Includes:
JSON::RubyEvents
Defined in:
lib/psych/visitors/json_tree.rb

Direct Known Subclasses

JSON::Stream

Instance Attribute Summary

Attributes inherited from YAMLTree

#finished, #started

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JSON::RubyEvents

#visit_DateTime, #visit_String, #visit_Time

Methods inherited from YAMLTree

#finish, #initialize, new, #push, #start, #tree, #visit_Array, #visit_BasicObject, #visit_BigDecimal, #visit_Class, #visit_Complex, #visit_DateTime, #visit_Encoding, #visit_Exception, #visit_Float, #visit_Hash, #visit_Integer, #visit_Module, #visit_NameError, #visit_NilClass, #visit_Object, #visit_Psych_Omap, #visit_Psych_Set, #visit_Range, #visit_Rational, #visit_Regexp, #visit_String, #visit_Struct, #visit_Symbol, #visit_Time

Constructor Details

This class inherits a constructor from Psych::Visitors::YAMLTree

Class Method Details

.create(options = {}) ⇒ Object



8
9
10
11
12
13
# File 'lib/psych/visitors/json_tree.rb', line 8

def self.create options = {}
  emitter = Psych::JSON::TreeBuilder.new
  class_loader = ClassLoader.new
  ss           = ScalarScanner.new class_loader
  new(emitter, ss, options)
end

Instance Method Details

#accept(target) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/psych/visitors/json_tree.rb', line 15

def accept target
  if target.respond_to?(:encode_with)
    dump_coder target
  else
    send(@dispatch_cache[target.class], target)
  end
end