There is a file db.json
Its content is:
[ { "user": "981" }, { "user": "859" }, { "user": "237" } ] For example, you need to check if there is a "user": "859" in db.json
How do I do it:
import json def json_read(file_name): try: json_data = json.load(open(file_name, 'r', encoding="cp1251")) except: json_data = [] return json_data data = json_read("db.json") user_in_db = "859" for user in data: if user_in_db == user['user']: print("yes") else: print("No") But I think in the case of a large number of users in db.json this method is less convenient. Is there any more convenient and faster way to do this?