I have a condition where, I get a hash
hash = {\"_id\"=>\"4de7140772f8be03da000018\", .....}
and I want this hash as
you can do
hash.inject({}){|option, (k,v) | option["id"] = v if k == "_id"; option}
This should work for your case!