input: Write a Python function to convert a CSV file to a JSON file.
  assert csv_to_json('data.csv', 'output.json') == True
  assert csv_to_json('sample.csv', 'result.json') == True
output: def csv_to_json(csv_file_path, json_file_path):
      import csv
      import json
  
      try:
          with open(csv_file_path, mode='r', newline='') as csv_file:
              csv_reader = csv.DictReader(csv_file)
              data = [row for row in csv_reader]
  
          with open(json_file_path, mode='w') as json_file:
              json.dump(data, json_file, indent=4)
  
          return True
      except Exception as e:
          print(f"An error occurred: {e}")
          return False