> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/code/builtin/data-transformation-functions/booleans.md).

# Duaer 布尔值上的转换方法

在 Duaer 表达式里，布尔值可以判断空不空，也可以转成数字或字符串。true 转成数字是 1，false 是 0。
## 方法

- isEmpty()：false、null、undefined 时返回 true；true 时返回 false。这不是单纯的“有没有字段”检查。
- isNotEmpty()：isEmpty() 的反面。
- toNumber()：true 变成 1，false 变成 0。
- toString()：变成字符串 true 或 false。

```
{{ $json.active.toNumber() }}
```
## Questions

### 在 Duaer 里 toNumber 的结果是什么？

在 Duaer 表达式里，true 变成 1，false 变成 0。toString() 变成字符串 true 或 false。

### Duaer 的 isEmpty 会不会把 false 当成空？

会。在 Duaer 表达式里，布尔上的 isEmpty() 在 false、null、undefined 时返回 true，在 true 时返回 false。它不是单纯的“有没有字段”检查。

