Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Psych.to_json
(?::JSON::State? state) -> ::String
to_json(object)
ext/psych/lib/psych.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/ext/psych/lib/psych.rb, line 623
def self.to_json object
visitor = Psych::Visitors::JSONTree.create
visitor << object
visitor.tree.yaml
end
Dump Ruby object to a JSON string.
See also
.safe_load_stream
.unsafe_load
.safe_load_file
.unsafe_load_file
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0