I am working on a Python code where I need to put a check on the assignment of a value to a key in a JSON object on the basis of user input. My approach is to create a check using the if-statement on the number of times of the occurrence of the specific key value, for that I need to count the number of times that specific key has already been occurred in the object.
I’ve a list of a large number of JSON objects in python in the following format:
Could you do
sum((1 for v in json.loads("...") if v.get("territory") == abc))