SELECT JSON_OBJECT( 'id', f.id, 'name', f.name, -- isBFF is stored as a TINYINT. In order to cast it to a proper BOOLEAN value, -- we need to compare it with the in-built BOOLEAN type. This will implicitly -- cast to TRUE or FALSE. 'isBFF', ( f.isBFF IS TRUE ), -- createdAt is stored as a DATETIME. In order to make it a bit more consumable -- in JavaScript, I like to convert it to UTC Milliseconds. 'createdAt', ( UNIX_TIMESTAMP( f.createdAt ) * 1000 ) ) AS payload FROM friend f ORDER BY f.id ASC ;