$ pip3.7 install jsonpath-ng
import json
from jsonpath_ng import jsonpath, parse
json_string = '{"id":1, "name":"Pankaj"}'
json_data = json.loads(json_string)
jsonpath_expression = parse('$.id')
match = jsonpath_expression.find(json_data)
print(match)
print("id value is", match[0].value)
import json
from jsonpath_ng import jsonpath, parse
with open("db.json", 'r') as json_file:
json_data = json.load(json_file)
print(json_data)
jsonpath_expression = parse('employees[*].id')
for match in jsonpath_expression.find(json_data):
print(f'Employee id: {match.value}')