JSON

How to convert yes/no, y/n, and 1/0 to true/false in JSON

2026-06-20
Task

A JSON flag arrives as a string: yes, ye, y, no, n, 1, or 0. The final JSON needs true and false values.

Short Answer

For a small set of values, add sequential replacements: replace y, yes, ye, and 1 with true; replace n, no, and 0 with false. If there are many variants, use regex rules.

How to do it in Eofferix with sequential transformations

  1. In the JSON editor, open the settings of the active value.
    Opening the active value settings in the Eofferix JSON editor
    The active value is highlighted; clicking it opens the node settings.
  2. In Transformations, add rules for Current value equals y, yes, ye, and 1; each rule uses action Replace with true.
  3. Add rules for negative values: Current value equals n, no, and 0; each rule uses action Replace with false.
    Sequential replacement rules from y yes ye 1 n no 0 to true and false
    The active settings show separate rules for each source value.
  4. Save the value settings.

How to do it in Eofferix with regular expressions

  1. Instead of several separate rules, keep the same active value settings and add two regex rules.
  2. First rule: condition Regular expression, value ^(yes|ye|y|1)$, action Replace with, result true.
  3. Second rule: condition Regular expression, value ^(no|n|0)$, action Replace with, result false.
    Regex rules that replace yes ye y 1 and no n 0 with true and false
    Two regex rules replace positive values with true and negative values with false.
  4. Save the value settings.

Before / After

Before

source data
[{"sku": "SKU-1001", "active": "y"}, {"sku": "SKU-1002", "active": "0"}]

After

result
[{"sku": "SKU-1001", "active": true}, {"sku": "SKU-1002", "active": false}]

Process data faster with Eofferix

Create a free account to automate catalogs and price lists around your own rules.

Sign up