页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

...

函数描述输出类型

min()

对于一个数值型数组,找到最小值

双精度

max()

对于一个数值型数组,找到最大值

双精度

avg()

对于一个数值型数组,求平均值

双精度

stddev()

对于一个数值型数组,求标准差

双精度

length()

求数组的长度

整型

sum()

对于一个数值型数组,求总和

双精度


示例

例如有下面的json结构:

代码块
linenumberstrue
{
    "store": {
        "book": [{
                "category": "reference",
                "author": "Nigel Rees",
                "title": "Sayings of the Century",
                "price": 8.95
            }, {
                "category": "fiction",
                "author": "Evelyn Waugh",
                "title": "Sword of Honour",
                "price": 12.99
            }, {
                "category": "fiction",
                "author": "Herman Melville",
                "title": "Moby Dick",
                "isbn": "0-553-21311-3",
                "price": 8.99
            }, {
                "category": "fiction",
                "author": "J. R. R. Tolkien",
                "title": "The Lord of the Rings",
                "isbn": "0-395-19395-8",
                "price": 22.99
            }
        ],
        "bicycle": {
            "color": "red",
            "price": 19.95
        }
    }
}


JsonPathResult
$.store.book[*].author所有 book 的 author 节点
$..author所有 author 节点
$.store.*store 下的所有节点,book 数组和 bicycle 节点
$.store..pricestore 下的所有 price 节点
$..book[2]匹配第 3 个 book 节点
$..book[(@.length-1)],或 $..book[-1:]匹配倒数第 1 个 book 节点
$..book[0,1],或 $..book[:2]匹配前两个 book 节点
$..book[?(@.isbn)]过滤含 isbn 字段的节点
$..book[?(@.price<10)]过滤price<10的节点
$..*递归匹配所有子节点