• 经典JsonPath表达式


    1、按照时间过滤,过滤 晚22点至01点之间的数据

    Jayway JsonPath evaluator

    测试数据:

    示例1:

    1. {
    2. "store": {
    3. "book": [
    4. {
    5. "category": "fiction",
    6. "time": "2022-10-01 21:10:01",
    7. "title": "Sword of Honour",
    8. "price": 12.99
    9. },
    10. {
    11. "category": "fiction",
    12. "time": "2022-10-01 22:10:01",
    13. "title": "Sword of Honour",
    14. "price": 12.99
    15. },
    16. {
    17. "category": "fiction",
    18. "time": "2022-10-01 23:10:01",
    19. "title": "Moby Dick",
    20. "isbn": "0-553-21311-3",
    21. "price": 8.99
    22. },
    23. {
    24. "category": "fiction",
    25. "time": "2022-10-01 00:10:01",
    26. "title": "The Lord of the Rings",
    27. "isbn": "0-395-19395-8",
    28. "price": 22.99
    29. },
    30. {
    31. "category": "fiction",
    32. "time": "2022-10-01 01:10:01",
    33. "title": "The Lord of the Rings",
    34. "isbn": "0-395-19395-8",
    35. "price": 22.99
    36. },
    37. {
    38. "category": "fiction",
    39. "time": "2022-10-01 02:10:01",
    40. "title": "The Lord of the Rings",
    41. "isbn": "0-395-19395-8",
    42. "price": 22.99
    43. },
    44. {
    45. "category": "fiction",
    46. "time": "2022-10-01 03:10:01",
    47. "title": "The Lord of the Rings",
    48. "isbn": "0-395-19395-8",
    49. "price": 22.99
    50. }
    51. ],
    52. "bicycle": {
    53. "color": "red",
    54. "price": 19.95
    55. }
    56. },
    57. "expensive": 10
    58. }

    JsonPath 表达式:

    $..book[?(@.time =~ /.* 22:.*|.* 23:.*|.* 00:.*|.* 01:.*/i)]

    返回结果:

    实例2:

    测试数据:

    1. {
    2. "category": "fiction",
    3. "time": "2022-10-01 03:10:01",
    4. "title": "The Lord of the Rings",
    5. "isbn": "0-395-19395-8",
    6. "price": 22.99
    7. }

     JsonPath 表达式:

    $[?( @.time=~ /.* 22:.*|.* 23:.*|.* 00:.*|.* 01:.*/i)]

    测试结果:

  • 相关阅读:
    Java并发 | 04.创建线程
    CSAPP bomblab
    goweb入门
    DS18B20数字温度计 (三) 1-WIRE总线 ROM搜索算法和实际测试
    用户行为分析-如何用数据驱动增长
    从旧金山到上海, HTTP/3 非常快!
    CenterNet复现
    驱动开发:内核枚举ShadowSSDT基址
    SpringBoot自动装配
    AutoEncoder和VAE
  • 原文地址:https://blog.csdn.net/shaokai132333/article/details/126651201