1、按照时间过滤,过滤 晚22点至01点之间的数据
测试数据:
示例1:
{
"store": {
"book": [
{
"category": "fiction",
"time": "2022-10-01 21:10:01",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"time": "2022-10-01 22:10:01",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"time": "2022-10-01 23:10:01",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"time": "2022-10-01 00:10:01",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
},
{
"category": "fiction",
"time": "2022-10-01 01:10:01",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
},
{
"category": "fiction",
"time": "2022-10-01 02:10:01",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
},
{
"category": "fiction",
"time": "2022-10-01 03:10:01",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
JsonPath 表达式:
$..book[?(@.time =~ /.* 22:.*|.* 23:.*|.* 00:.*|.* 01:.*/i)]
返回结果:
实例2:
测试数据:
{
"category": "fiction",
"time": "2022-10-01 03:10:01",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
JsonPath 表达式:
$[?( @.time=~ /.* 22:.*|.* 23:.*|.* 00:.*|.* 01:.*/i)]
测试结果: