Try it like this:
$employee_data = array();
$categories = array();
$employee_data["mapwidth"] ="2000";
$employee_data["mapheight"] ="2000";
while($row = $result->fetch_array(MYSQL_ASSOC)) {
$categories[] = $row;
}
$employee_data["categories"] =$categories;
echo json_encode($employee_data);
Refer to this answer to further improve your code.
4
solved How would I be able to create brackets around my json file using PHP?