Slim can use withJson() that can return JSON responses with desired route and method
$app = new \Slim\App();
$app->get('/api/person', function ($request, $response, $args) {
$payload=[];
array_push($payload, array("name"=>"Bob" ,"birth-year"=>1993));
array_push($payload, array("name"=>"Alice","birth-year"=>1995));
return $response->withJson($payload,200);
});
$app->run();
Try it with curl
`curl -X GET http://127.0.0.1/api/person`
it can return an array in json
[{"name":"Bob","birth-year":1993},{"name":"Alice","birth-year":1995}]