小编Fab*_*ngo的帖子

空的 JSON 返回 - Symfony3

我是 PHP 和 Symfony 3 的初学者,我遇到了一个问题:json_encode 返回空对象。您可以检查下面的图像和代码。

/**
 * @Rest\Get("/user")
 */
public function getAction()
{
    $restresult = $this->getDoctrine()->getRepository('AppBundle:User')->findAll();
    if ($restresult === null) {
        return new View("there are no users exist", Response::HTTP_NOT_FOUND);
    }

    return new Response(json_encode($restresult), Response::HTTP_OK);
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

php json symfony

2
推荐指数
1
解决办法
3128
查看次数

标签 统计

json ×1

php ×1

symfony ×1