These answers are a bit dated. Therefore I give you:
hash = JSON.parse string
Rails should automagically load the json
module for you, so you don’t need to add require 'json'
.
More Related Contents:
- How to “pretty” format JSON output in Ruby on Rails
- In Rails, how do you render JSON using a view?
- How to convert a ruby hash object to JSON?
- POST json to rails server
- JSON encoding wrongly escaped (Rails 3, Ruby 1.9.2)
- Rails Object Relationships and JSON Rendering
- How to prevent browser page caching in Rails
- do..end vs curly braces for blocks in Ruby
- In Ruby on Rails, to extend the String class, where should the code be put in?
- Submit POST data from controller to another website in Rails
- What does map(&:name) do in this Ruby code?
- STI, one controller
- LEFT OUTER joins in Rails 3
- HEROKU – cannot run git push heroku master [duplicate]
- Error when running rails app – ExecJS::RuntimeError
- How to `bundle install` when your Gemfile requires an older version of bundler?
- rails4 unknown encoding name – CP720
- Find unused code in a Rails app
- What is the difference between Ruby and Ruby on Rails?
- Paginating an Array in Ruby with will_paginate
- Find number of months between two Dates in Ruby on Rails
- undefined method `visit’ when using RSpec and Capybara in rails
- nokogiri gem installation error
- How to edit or write on existing PDF with Ruby?
- Ruby: problem installing EventMachine under Windows 7
- What is the difference between pluck and collect in Rails?
- Looking for suggestions for building a secure REST API within Ruby on Rails
- Installing Ruby on Rails – Mac OS Lion
- Ruby: Create range of dates
- Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432?