Why json_object start with comma?

Hi I’ve got the following code:

                             WHEN buildings_join.permission = '1'
                             THEN JSON_OBJECT('buildingName',
                             ELSE '' END ),
         ']') AS user_buildings

when I’ve got only one value in the database I get the following

[,{"buildingID": 2, "buildingName": "Via umberto"}]

If I’ve got two values then I get the following:

[{"buildingID": 1, "buildingName": "Via roma"},{"buildingID": 2, "buildingName": "Via umberto"}]

Now how can I remove the comma after [ when I’ve only got one value? many thanks

why does that comma after the square bracket disappear if there are two values?

Hi @r937 i’ve got no idea. I’ve sorted it out with php at the moment.