How to convert a Ruby object to JSON April 19, 2023 by Tarik Yes, you can do it with to_json. You may need to require 'json' if you’re not running Rails.