Attempt to convert `as_json` options to a Hash

This avoid errors when serializing models with `JSON.generate`,
where the given option isn't a Hash but a State object, where
a `NoMethodError: undefined method `key?' for JSON::Ext::Generator::State`
error would appear.

/cc @rafaelfranca