【发布时间】:2021-05-17 06:51:45
【问题描述】:
我一直在研究 JMESPath 的官方文档和一些其他资源。但是我没有成功完成以下任务:
我的数据结构是来自 vimeo api(视频列表)的 json: 数据数组包含很多对象,每个对象都是上传的文件,有很多属性和各种选项。
"data": [
{
"uri": "/videos/00001",
"name": "Video will be added.mp4",
"description": null,
"type": "video",
"link": "https://vimeo.com/00001",
"duration": 9,
"files":[
{
"quality": "hd",
"type": "video/mp4",
"width": 1440,
"height": 1440,
"link": "https://player.vimeo.com/external/4443333.sd.mp4",
"created_time": "2020-09-01T19:10:01+00:00",
"fps": 30,
"size": 10807854,
"md5": "643d9f18e0a63e0630da4ad85eecc7cb",
"public_name": "UHD 1440p",
"size_short": "10.31MB"
},
{
"quality": "sd",
"type": "video/mp4",
"width": 540,
"height": 540,
"link": "https://player.vimeo.com/external/44444444.sd.mp4",
"created_time": "2020-09-01T19:10:01+00:00",
"fps": 30,
"size": 1345793,
"md5": "cb568939bb7b276eb468d9474c1f63f6",
"public_name": "SD 540p",
"size_short": "1.28MB"
},
... other data
]
},
... other uploaded files
]
我需要应用的过滤器是持续时间需要小于10,文件宽度需要为540,结果需要包含来自文件的链接(url)
我已经设法使只有一个结构级别正常工作:
data[].files[?width == '540'].link
我需要提取这种列表
[
{
"uri": "/videos/111111",
"link": "https://player.vimeo.com/external/4123112312.sd.mp4"
},
{
"uri": "/videos/22222",
"link": "https://player.vimeo.com/external/1231231231.sd.mp4"
},
...other data
]
【问题讨论】:
标签: json html5-video vimeo vimeo-api jmespath