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
- In the JSON editor, open the settings of the
activevalue.
The active value is highlighted; clicking it opens the node settings. - In Transformations, add rules for Current value equals
y,yes,ye, and1; each rule uses action Replace withtrue. - Add rules for negative values: Current value equals
n,no, and0; each rule uses action Replace withfalse.
The active settings show separate rules for each source value. - Save the value settings.
How to do it in Eofferix with regular expressions
- Instead of several separate rules, keep the same
activevalue settings and add two regex rules. - First rule: condition Regular expression, value
^(yes|ye|y|1)$, action Replace with, resulttrue. - Second rule: condition Regular expression, value
^(no|n|0)$, action Replace with, resultfalse.
Two regex rules replace positive values with true and negative values with false. - 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}]