内置函数

内置函数 #

TimeStamp #

获取当前时间戳:${TimeStamp}


Date #

格式化输出当前日期: ${Date(yyyy-MM-dd HH:mm:ss)}

格式化输出明天日期: ${Date(yyyy-MM-dd, 1, D)}

格式化输出昨天日期: ${Date(yyyy-MM-dd, -1, D)}

格式化输出当前时间一小时后的日期: ${Date(yyyy-MM-dd HH:mm:ss, 1, H)}

格式化输出当前时间一小时前的日期: ${Date(yyyy-MM-dd HH:mm:ss, -1, H)}

格式化输出当前时间一分钟后的日期: ${Date(yyyy-MM-dd HH:mm:ss, 1, M)}

格式化输出当前时间一分钟前的日期: ${Date(yyyy-MM-dd HH:mm:ss, -1, M)}


RandomNumber #

随机生成指定长度的纯数字字符串:${RandomNumber(3)}


RandomString #

随机生成指定长度的字符串:${RandomString(3)}


JsonExtractor #

根据 JsonPath 提取 Json 字段的值

例如变量 jsonData = {“title”: “JSON Example”,“author”: {“name”: “John Doe”,“age”: 35,“isVerified”: true},“tags”: [“json”, “syntax”, “example”],“rating”: 4.5,“isPublished”: false,“comments”: null}

提取字段值: ${JsonExtractor(${jsonData}, $.author.name)}


Math #

普通公式计算: ${Math((6 * 2 - 1 + 3) / 3)}

指定小数点位数及舍入方式: ${Math((6 * 2 - 1 + 3) / 3, 2, HALF_UP)}

舍入方式的值: HALF_UP 、HALF_DOWN 、HALF_EVEN


Round #

例如变量 a = 3.1415926

保留两位小数: ${Round(${a}, 2, HALF_UP)}