I'm doing a coding exercise where I need to read & parse from a JSON file in Ruby however it asks that I should keep the solution open ended in case other file types are used in future. I've coded it specifically for JSON currently but I can't think of a way to do this to cater for other file types without using regex - this again would probably be file type specific though because I'd be looking for the data to be formatted in a specific way.
Does anyone have any ideas on how I could do this to work for multiple different file types?
json_from_file = File.read("test.json")
hash = JSON.parse(json_from_file)