and the gems json depending of your version of ruby
require 'json'
value = '{"val":"test","val1":"test1","val2":"test2"}'
puts JSON.parse(value) # => {"val"=>"test","val1"=>"test1","val2"=>"test2"}
This article might help : https://hackhands.com/ruby-read-json-file-hash/
PS It's a huge security risk to accept input with these character: # => {"}
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.