一个好用的json库 用来处理一些大json 再也不用循环读取了
import json
import jsonpath as jsonpath
strData = '{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}'
jsonData = json.loads(strData)
#绝对路径
checkUrl = "$.store.bicycle.color"
result = jsonpath.jsonpath(jsonData,checkUrl)
print(result)
#相对路径
checkUrl2 = "$..price"
result2 = jsonpath.jsonpath(jsonD