input: Write a function to modify the following Python code to handle errors. The input code is a function that reads data from a JSON file. The output code should include error handling for cases where the file does not exist and where the file is not in a valid JSON format.  
  Function header: def read_data_from_json(filename):  
  assert read_data_from_json("nonexistent_file.json") == None  
  assert read_data_from_json("invalid_json_file.json") == None  
  assert read_data_from_json("valid_file.json") == {"key": "value"}
output: def read_data_from_json(filename):
      try:
          with open(filename, 'r') as file:
              data = json.load(file)
              return data
      except FileNotFoundError:
          return None
      except json.JSONDecodeError:
          return None