tnblog
首页
视频
资源
登录

jsonpath

4435人阅读 2022/11/8 18:51 总访问:94820 评论:0 收藏:0 手机
分类: python
  1. from jsonpath import jsonpath
  2. book_dict = {
  3.     "store": {
  4.         "book": [
  5.             {"category""reference",
  6.              "author""Nigel Rees",
  7.              "title""Sayings of the Century",
  8.              "price"8.95
  9.              },
  10.             {"category""fiction",
  11.              "author""Evelyn Waugh",
  12.              "title""Sword of Honour",
  13.              "price"12.99
  14.              },
  15.             {"category""fiction",
  16.              "author""Herman Melville",
  17.              "title""Moby Dick",
  18.              "isbn""0-553-21311-3",
  19.              "price"8.99
  20.              },
  21.             {"category""fiction",
  22.              "author""J. R. R. Tolkien",
  23.              "title""The Lord of the Rings",
  24.              "isbn""0-395-19395-8",
  25.              "price"22.99
  26.              }
  27.         ],
  28.         "bicycle": {
  29.             "color""red",
  30.             "price"19.95
  31.         }
  32.     }
  33. }
  34. print(jsonpath(book_dict, '$..book[?(@.category == "fiction")]'))
  35. print(jsonpath(book_dict, '$..book[?(@.author)]'))
  36. print(jsonpath(book_dict, '$..book[?(@.price < 10)]'))
  37. print(jsonpath(book_dict, '$..bicycle.color'))


评价
1
排名
34
文章
19
粉丝
1
评论
1
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术