I am working with a Rails database that contains serialized values in one column. These values should have been regular Hash
es, but due to improperly sanitizing the parameters they were stored as HashWithIndifferentAccess
or Parameters
. For example, one column entry looks like this:
--- !ruby/object:ActionController::Parameters
parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
windowHeight: 946
documentHeight: 3679
scrollTop: 500
permitted: false
I want to read this with Python's yaml
implementation, but when I try to do so, I get:
*** yaml.constructor.ConstructorError: could not determine a constructor for the tag '!ruby/object:ActionController::Parameters'
in "<unicode string>", line 1, column 5:
--- !ruby/object:ActionController::P ...
^
So, for some reason it expects a constructor. But quite obviously, the value itself is just a regular dictionary. How can I still read it?