将JSON发布到Codeigniter控制器 [英] Post JSON to Codeigniter controller
本文介绍了将JSON发布到Codeigniter控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Codeigniter接收和解析POST请求中发送的JSON对象,但无法查找"它.
I am trying to receive and parse a JSON object sent in a POST request using Codeigniter but I cannot "find" it.
这是我的控制器代码:
public function parse () {
$json = $this->input->post();
$json = stripslashes($json);
$json = json_decode($json);
print_r($json);
}
这是我的JSON对象:
This is my JSON object:
{"data":"value"}
推荐答案
这是正确的方法.
$input_data = json_decode(trim(file_get_contents('php://input')), true);
这篇关于将JSON发布到Codeigniter控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文