Here’s an easy way to do it:
def function(json_object, name):
for dict in json_object:
if dict['name'] == name:
return dict['price']
If you are sure that there are no duplicate names, an even more effective (and pythonic) way to do it is to use list comprehensions:
def function(json_object, name):
return [obj for obj in json_object if obj['name']==name][0]['price']
4
solved The Fastest method to find element in JSON (Python) [duplicate]