php对象转换成Json的有关问题

WBOY
Release: 2016-06-13 11:53:18
Original
873 people have browsed it

php对象转换成Json的问题

<br />用的CI框架,在model里面有一个team_model<br />$this->load->model('Team_model');<br />$team=new Team_model;<br />$team->Id=1;<br />$team->Code='001';<br />$team->Caption='aa';<br />$jsonstr=json_encode($team);//这样转换的不对。先转成数组在用json_encode也不对。<br />//json格式要是{“team”:{"Id":1,"Code":"001","Caption":"aa"}};<br />//不用model用数组可以实这个<br />如:<br />$team['Id']=1;<br />$team['Code']='001';<br />$team['Caption']='aa';<br />$arrteam['team']=$team;<br />$jsonstr=json_encode($arrteam);<br />这样是可以实现但是没有用到model,MVC的框架用不到model,呵呵。。。。这还叫MVC吗。这太奇怪了。 让我凌乱了<br />
Copy after login

------解决方案--------------------

------解决方案--------------------
$team是对象,直接json_encode当然不对。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template