JSON-返回已过滤JSON路径的长度

问题描述

我正在尝试获取过滤的JSON路径中返回的记录数,例如

$.Visits[?(@.LateCancelled==false)]

这是我正在过滤的JSON-我正在尝试检索"LateCancelled"=false

的记录数
{
    "PaginationResponse": {
        "RequestedLimit": 100,"RequestedOffset": 0,"PageSize": 2,"TotalResults": 2
    },"Visits": [
        {
            "AppointmentId": 0,"LateCancelled": false,"SiteId": -99,"Action": "None"
        },{
             "AppointmentId": 0,{
            "AppointmentId": 0,"LateCancelled": true,"Action": "None"

        }
    ]
}

如果我使用

$.Visits.length 

返回“ 3”(符合预期)

如果我使用以下内容

$.Visits[?(@.LateCancelled==false)]

它将返回两个匹配的结果(再次如预期的那样)

[
  {
    "AppointmentId": 0,"Action": "None"
  },{
    "AppointmentId": 0,"Action": "None"
  }
]

但是,我似乎无法弄清楚如何获得过滤后的结果集的长度,例如$.Visits[?(@.LateCancelled==false)].length

我希望返回“ 2”。这可能吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)