JSONPath - 按名称包含“@”的字段过滤

JSONPath - filter by field that name contain '@'

我JSON喜欢:

{
    "media": {
        "@ref": "https://Bull_FTR.mpg",
        "track": [{
            "@type": "General",
            "VideoCount": "1"
        }, {
            "@type": "Video",
            "StreamOrder": "0"
        }, {
            "@type": "Audio",
            "StreamOrder": "1"
        },
        {
            "@type": "Audio",
            "StreamOrder": "2"
        }]
    }
}

并且我需要查询 mwdia.tracks 中具有 @type = 'Audio' 的所有字段。问题是我要过滤的字段包含“@”,而我的查询 $.media.track[?(@.['@type'] == 'Audio')] 不起作用。我做错了什么?

简单的方法是用十六进制代码 (\x40) 直接将“@”字符替换为您的 jsonpath 查询:

$.media.track[?(@['\x40type']=="Audio")]