check if data exists in json python

new_data = {"text":text }
        
        with open("data.json",'r+') as file:
            file_data = json.load(file)
            if text in file_data["details"].__str__():
                print(True)
            else:
                file_data["details"].append(new_data)
                file.seek(0)
                json.dump(file_data, file, indent = 4)



Leave a Reply