You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用SharePoint JSON Formatter将布尔值显示为Yes/No而非true/false的实现方法

SharePoint布尔列JSON格式化转Yes/No解决方案

你需要调整txtContent的取值逻辑,使用列格式化内置的条件表达式判断当前字段值即可,修改后的完整代码如下:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block"
      }
    },
    {
      "elmType": "span",
      "txtContent": "=if(@currentField == true, 'Yes', 'No')"
    }
  ]
}

核心修改说明

  • 原来直接绑定@currentField会输出原生布尔值true/false,替换为=if(@currentField == true, 'Yes', 'No')表达式后,会自动根据字段值返回对应文本
  • 如果需要显示中文的「是/否」,直接把表达式里的Yes和No替换为对应中文即可

内容的提问来源于stack exchange,提问作者Chester

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 22:15:01