diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-02-17 22:44:26 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-02-17 22:44:26 -0800 |
commit | ebf212880db752979336cfc613bac7c3d0d83d32 (patch) | |
tree | bd9853664f5dab8da1d34f817516a54e0d05a219 /lib/psych.rb | |
parent | 7e3a927e6b7e1a63bc16b9c74eb931dc3eb6a983 (diff) | |
download | psych-ebf212880db752979336cfc613bac7c3d0d83d32.zip |
adding basic json support
Diffstat (limited to 'lib/psych.rb')
-rw-r--r-- | lib/psych.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/psych.rb b/lib/psych.rb index 0c4a7ee..5f66849 100644 --- a/lib/psych.rb +++ b/lib/psych.rb @@ -144,6 +144,14 @@ module Psych end ### + # Dump Ruby object +o+ to a JSON string. + def self.to_json o + visitor = Psych::Visitors::JSONTree.new(:json => true) + visitor.accept o + visitor.tree.to_yaml + end + + ### # Load multiple documents given in +yaml+, yielding each document to # the block provided. def self.load_documents yaml, &block |