I am trying to create a function that takes an input. Which in this case is a tracking code. Look that tracking code up in a JSON file then return the tracking code as output. The json file is as follows:
[ { "tracking_number": "IN175417577", "status": "IN_TRANSIT", "address": "237 Pentonville Road, N1 9NG" }, { "tracking_number": "IN175417578", "status": "NOT_DISPATCHED", "address": "Holly House, Dale Road, Coalbrookdale, TF8 7DT" }, { "tracking_number": "IN175417579", "status": "DELIVERED", "address": "Number 10 Downing Street, London, SW1A 2AA" } ] I have started using this function:
def compare_content(tracking_number) File.open("pages/tracking_number.json", "r") do |file| file.print() end Not sure how I would compare the input to the json file. Any help would be much appreciated.