input: Write a Python function to connect to a MongoDB database, import data from a JSON file, and insert it into a specified collection. 
  assert insert_data_to_mongo('mongodb://localhost:27017/', 'myDatabase', 'myCollection', 'data.json') == True
output: def insert_data_to_mongo(mongo_uri, db_name, collection_name, json_file):
      from pymongo import MongoClient
      import json
  
      try:
          # Connect to MongoDB
          client = MongoClient(mongo_uri)
          db = client[db_name]
          collection = db[collection_name]
  
          # Read JSON file
          with open(json_file, 'r') as file:
              data = json.load(file)
  
          # Insert data into collection
          if isinstance(data, list):
              collection.insert_many(data)
          else:
              collection.insert_one(data)
  
          return True
      except Exception as e:
          print(f"An error occurred: {e}")
          return False