Jsonpath 只查询一项

Jsonpath querying only one item

我在使用 json 路径仅找出 json 中的确定值时遇到问题。 我有这个 json:

{"tvs": {
    {  "tv": [
    {
      "serial": "HD1300",
      "data": [
        {
          "title": "manufacturer",
          "value": "lg"
        },
        {
          "title": "color",
          "value": "silver"
        },
        {
          "title": "inches",
          "value": 32
        },
        {
          "title": "connection",
          "value": 220
        },

        {
          "title": "connection",
          "value": 400
        }
    ]

    }.. more tvs

我想知道序列号 hd1300 是否存在值 connection:400 我已经尝试过:

$.tvs.[?(@.serial=='hd1340')].data.[?(@.title== 'connection'),(@.value==400)]

但我的问题是我还用 200 检索了 "connection"。我怎样才能过滤以仅获取此值?

我认为您的 JSON 可能有误(tvs 和 tv 之间的额外支撑)。我能够让它在 http://jsonpath.com.

上运行
{"tvs": 
    {  "tv": [
    {
      "serial": "HD1300",
      "data": [
        {
          "title": "manufacturer",
          "value": "lg"
        },
        {
          "title": "color",
          "value": "silver"
        },
        {
          "title": "inches",
          "value": 32
        },
        {
          "title": "connection",
          "value": 220
        },
        {
          "title": "connection",
          "value": 400
        }
        ]}
    ]}
}

$.tvs.tv.[?(@.serial=='HD1300')].data.[?(@.title=='connection' && @.value== '400')]