【发布时间】:2021-12-12 16:09:58
【问题描述】:
我正在使用Phalcon 4,并以 JSON 格式向 Phalcon 控制器发送 POST。
JSON 是:
birthday "12/12/2020"
country "ddf"
id "15bbde30-3714-11ec-95e7-8163123e4768"
name "df"
但是当我分析它时:
public function post(): ResponseInterface
{
$this->view->disable();
$body = $this->request->getJsonRawBody();
return $this->response->setStatusCode(502)->setContent(json_encode(($body-> birthday)));
结果是:
"12\/12\/2020"
我不明白为什么 Phalcon 会添加这个奇怪的符号 \/
如果我再做一次类似的测试(我已经删除了-> birthday):
public function post(): ResponseInterface
{
$this->view->disable();
$body = $this->request->getJsonRawBody();
return $this->response->setStatusCode(502)->setContent(json_encode(($body)));
我有例外的结果:
birthday "12/12/2020"
country "ddf"
id "15bbde30-3714-11ec-95e7-8163123e4768"
name "df"
你有没有办法避免它?
【问题讨论】:
标签: phalcon