Validators
对值的检查。
每个示例都在已部署的表达式引擎上、基于页面末尾的示例上下文运行过。
$isEmpty
当 value 没有可枚举的自有键时返回 true:{}、[]、''、null 和 undefined。它检查的是键而非内容:只看第一层({ a: {} } 不为空),并且对没有键的数字和布尔值返回 true。
参数
-
valueany 必填 - 通常是对象或列表。
返回
boolean 没有自有键时为 true。
示例
结果 boolean
结果 boolean
未执行的节点输出为空。
结果 boolean
数字没有键:结果为 true。
结果 boolean
说明
- 对于缺失或为空的字段,
$ifEmpty更易读。切勿对数字或布尔值使用$isEmpty。
在 JSONata 中 $$isEmpty(query)
示例上下文
示例基于以下数据运行:当前节点的输入($json)、已运行的节点($(…))、本次运行的 ID 以及当前节点。时钟固定为 2026-11-26T14:30:00.000Z,服务器时区为 UTC,因此各页面中 $now 与 $today 的值都相同。
当前节点的输入
{
"$json": {
"body": {
"order_id": "ord_1042",
"email": "[email protected]",
"customer": {
"name": "Ana Pérez",
"segment": "gold"
},
"priority": "",
"items": [
{
"sku": "A-100",
"qty": 2,
"price": 10.5
},
{
"sku": "B-200",
"qty": 0,
"price": 4
},
{
"sku": "C-300",
"qty": 1,
"price": 25
}
],
"tags": [
"new",
"web",
"new"
],
"created_at": "2026-11-25T09:15:00Z"
},
"headers": {
"content-type": "application/json"
},
"query": {},
"method": "POST"
}
} 已运行的节点(标签 → 输出)
{
"Webhook Receiver": "= $json",
"Normalize input": {
"correlation_id": "c-7f3a",
"channel": "web"
},
"Classify": {
"label": "billing",
"confidence": 0.92
}
} 运行与当前节点
{
"$execution": {
"id": "fir-xxxx",
"flow_instance_id": "fi-xxxx",
"flow_definition_id": "fd-xxxx",
"flow_version_id": "fv-xxxx",
"flow_slug": "order-intake"
},
"$node": {
"id": "node-notify",
"label": "Notify customer"
}
} 示例运行所基于的编排器提交 31e874b