I have the following function in my controller file where I have a string and I am trying to parse it using JSON.parse. The problem I am facing is that I am not able to print the value of message which is present in the hash that is being returned.
def index
.........
r = '{"response":"{\"message\":\"The following page was successfully Created 3035\",\"success\":\"0\",\"page_id\":\"3035\"}"}'
@hash = JSON.parse(r)
respond_to do |format|
format.html
end
end
In my view file I am using the following code
<%= @hash['response']['message'] %>
The output that I am getting is message instead of getting The following page was successfully Created 3035
I have 'require json' on my controller file.
If I do
<%= @hash['response'] %>
Then I get the whole hash.Please help
rvalue ?