Prefer as_json to to_hash for casting