marting
2 years agoNeophyte
JSON Path capability in a Webpage DataSource
I think the answer to this is gonna be “You need to script it, dummy”, but figured I’d check anyway... I'm working on a new DataSource that pulls/interprets JSON data from a peudo-custom system via ...
- Anonymous2 years ago
There’s an easier way than this:
function parseBooleanValue(value) {
if (value === 'true') {
return 1;
} else if (value === 'false') {
return 0;
} else {
return null; // or throw an error, depending on how you want to handle invalid values
}
}It uses the ternary operator:
(value == "true") ? 1 : 0
This is exactly equivalent to:
if (value == "true") {
return 1
} else {
return 0
}No need for a function at all, it’s overkill.