input: Write a python function to train a Naive Bayes classifier to predict the class of a given text from a JSON file containing training data.
  assert train_and_predict("this is a sample text", "training_data.json") in ["class1", "class2", "class3"]
  assert train_and_predict("another example text", "training_data.json") in ["class1", "class2", "class3"]
  assert train_and_predict("yet another text", "training_data.json") in ["class1", "class2", "class3"]
output: def train_and_predict(text, json_file):
      import json
      from sklearn.feature_extraction.text import CountVectorizer
      from sklearn.naive_bayes import MultinomialNB
      from sklearn.pipeline import make_pipeline
  
      # Load training data from the JSON file
      with open(json_file, 'r') as file:
          training_data = json.load(file)
  
      texts = [item['text'] for item in training_data]
      labels = [item['class'] for item in training_data]
  
      # Create a pipeline that vectorizes the text and trains a Naive Bayes classifier
      model = make_pipeline(CountVectorizer(), MultinomialNB())
  
      # Train the model
      model.fit(texts, labels)
  
      # Predict the class of the input text
      prediction = model.predict([text])[0]
  
      return prediction