Php object conversion to Json
In the CI framework used, there is a team_model $ this-> load-> model ('Team _ Model') in the model; $ Team = new Team_model; $ team-> Id = 1; $ team-> Code = '001'; $ team-> Caption = 'a'; $ jsonstr = json_encode ($ team ); // The conversion is incorrect. It is not correct if json_encode is used to convert the data to an array first. // Json format: {"team": {"Id": 1, "Code": "001", "Caption": "aa "}}; // you can use arrays without using the model, for example, $ team ['id'] = 1; $ team ['code'] = '001 '; $ team ['Caption '] = 'a'; $ arrteam ['team'] = $ team; $ jsonstr = json_encode ($ arrteam ); in this way, model can be implemented but model is not used. the MVC framework cannot use model .... Is it also called MVC. This is so strange. Make me messy
Reply to discussion (solution)
The problem has been solved. please come in and take the score.
$ Team is an object. json_encode is incorrect.
How can I deal with this problem?