json returned from CI REST API is failing jsonlint tests

后端 未结 3 633
天涯浪人
天涯浪人 2021-01-28 08:05

I have the following code in a codeigniter REST app (built using: https://github.com/chriskacerguis/codeigniter-restserver)

public function fullname_get()
{
   $         


        
3条回答
  •  别那么骄傲
    2021-01-28 08:42

    You have to strip slashes, use this stripslashes(json_encode($fullname)). Full code mention below:

    public function fullname_get()
    {
       $fullname = array("fname"=>"john", "lname"=>"doe");
       $data["json"] = stripslashes(json_encode($fullname));
       $this->response($data["json"], 200);
    }
    

    I hope this will solve your issue.

提交回复
热议问题