How to replace a hash key with another key

I have a condition where, I get a hash

  hash = {"_id"=>"4de7140772f8be03da000018", .....}

and I want this hash as

  hash = {"id"=>"4de7140772f8be03da000018", ......}

P.S: I don’t know what are the keys in the hash, they are random which comes with an “_” prefix for every key and I want no underscores

12 Answers
12

Leave a Comment