I am using Ruby on Rails 3 and I am trying to convert the following JSON data.
"{\"errors\":{\"base\":\"Invalid field.\"}}"
to a hash accessible this way:
@internal_test1[:errors][:base]
# => "Invalid field"
How to do it?
UPDATE
@internal_test1 = "{\"errors\":{\"base\":\"Invalid email/password combination.\"}}"
test = ActiveSupport::JSON.decode(@internal_test1)
@internal_test2 = test["errors"]
Debugging
@internal_test1
--- "{\"errors\":{\"base\":\"Invalid email/password combination.\"}}"
@internal_test2
---
base: Invalid email/password combination.
source
share