gpt4 book ai didi

php - FOSRestBundle - 响应数据操作

转载 作者:行者123 更新时间:2023-12-04 01:45:13 27 4
gpt4 key购买 nike

我正在使用FOSRestBundle。我想返回用户信息,但数据信息较少......如何做到这一点?这是我当前的回复

{
"id": 1,
"user": {
"id": 1,
"username": "qqqq",
"username_canonical": "qqqq",
"email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="67090e02270a060a490008" rel="noreferrer noopener nofollow">[email protected]</a>",
"email_canonical": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b9d7d0dcf9d4d8d497ded6" rel="noreferrer noopener nofollow">[email protected]</a>",
"enabled": true,
"salt": "9ds56htrvvokkckgscs0084so8ss40g",
"password": "ZcmowLmoNVLNfdMLakzp29G3TZKIfJWVWZ7sE3iylKin5dlYDIQfAJvDC6CFAS2PI4KcpJM0A8qPihDU6jH02A==",
"last_login": "2016-04-03T18:45:06+0200",
"locked": false,
"expired": false,
"roles": [],
"credentials_expired": false,
"created_at": "2016-04-03T18:45:06+0200",
"updated_at": "2016-04-03T18:45:06+0200"
},
"text": "asdadadasd",
"uv": 0,
"dv": 0,
"vote_count": 0,
"public_i_p": "",
"private_i_p": "",
"voters": [],
"created_at": "-0001-11-30T00:00:00+0124",
"updated_at": "-0001-11-30T00:00:00+0124"
}

我不想显示所有用户信息,只想显示用户名、已锁定、已过期

我的回应

public function getEntryAction(Entry $entry)
{
return View::create()
->setStatusCode(200)
->setData($entry);
}

最佳答案

我可以推荐JMSSerializerBundle。它无缝集成,您可以定义要序列化的属性。

Bundle documentation

Annotation reference

关于php - FOSRestBundle - 响应数据操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36389078/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com