input: Write a function to parse a JSON data structure and return the name, age, and occupation from the given data. If the data is invalid or missing any of these fields, raise a ValueError.
  def parse_json(data):
   if not isinstance(data, dict):
   raise ValueError("Input data must be a dictionary")
   if 'name' not in data or 'age' not in data or 'occupation' not in data:
   raise ValueError("Missing required fields: name, age, or occupation")
   return data['name'], data['age'], data['occupation']
  
  assert parse_json({"name": "John", "age": 18, "occupation": "Software Engineer"})==("John", 18, "Software Engineer")
  assert parse_json({"name": "Alice", "age": 25, "occupation": "Teacher"})==("Alice", 25, "Teacher")
  assert parse_json({"name": "Bob", "age": 30}) # This will raise a ValueError
  assert parse_json("invalid data") # This will raise a ValueError
output: def parse_json(data):
   if not isinstance(data, dict):
   raise ValueError("Input data must be a dictionary")
   if 'name' not in data or 'age' not in data or 'occupation' not in data:
   raise ValueError("Missing required fields: name, age, or occupation")
   return data['name'], data['age'], data['occupation']