diff options
Diffstat (limited to 'ext/psych/lib/psych/visitors/json_tree.rb')
-rw-r--r-- | ext/psych/lib/psych/visitors/json_tree.rb | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/ext/psych/lib/psych/visitors/json_tree.rb b/ext/psych/lib/psych/visitors/json_tree.rb index 774b043ba4..0ec1678a39 100644 --- a/ext/psych/lib/psych/visitors/json_tree.rb +++ b/ext/psych/lib/psych/visitors/json_tree.rb @@ -1,14 +1,16 @@ module Psych module Visitors class JSONTree < YAMLTree + def initialize options = {}, emitter = Psych::JSON::TreeBuilder.new + super + end + def visit_NilClass o - scalar = create_scalar( - 'null', nil, nil, true, false, Nodes::Scalar::PLAIN) - append scalar + @emitter.scalar 'null', nil, nil, true, false, Nodes::Scalar::PLAIN end def visit_Integer o - append create_scalar(o.to_s, nil, nil, true, false, Nodes::Scalar::PLAIN) + @emitter.scalar o.to_s, nil, nil, true, false, Nodes::Scalar::PLAIN end def visit_Float o @@ -17,31 +19,11 @@ module Psych end def visit_String o - append create_scalar o.to_s + @emitter.scalar o.to_s, nil, nil, false, true, Nodes::Scalar::ANY end alias :visit_Symbol :visit_String private - def create_document - doc = super - doc.implicit = true - doc.implicit_end = true - doc - end - - def create_mapping - map = super - map.style = Nodes::Mapping::FLOW - map - end - - def create_scalar value, anchor = nil, tag = nil, plain = false, quoted = true, style = Nodes::Scalar::ANY - super - end - - def create_sequence anchor = nil, tag = nil, implicit = true, style = Nodes::Sequence::FLOW - super - end end end end |