I would like my MySql query to return a JSON object that looks as follows:
{"name": "Piotr", "likesMysql": true}
This seems to be working fine when I do:
SELECT json_object(
'name', 'Piotr',
'likesMysql', TRUE
)
However when I try to derive the likesMysql
from an if
expression I get
0
and 1
instead of false
and true
e.g.:
SELECT json_object(
'name', 'Piotr',
'likesMysql', if(4 MOD 2 = 0, TRUE, FALSE)
)
results in
{"name": "Piotr", "likesMysql": 1}
How do I use the json_object
to construct a JSON object that has true
or false
as property value?