Home backslash being add to url of array after json_encode
Reply: 0

backslash being add to url of array after json_encode

user2720 Published in August 16, 2018, 6:14 am

Actually I am using php codeigniter as a server side language.So when I am try to send the array to android application using json_encode the unwanted backslash being added every time in the user_image url only but the other data of array remain unchanged.

here is my php codeigniter controller code.

class Groups extends CI_Controller
    public function groupmember()
        echo json_encode($data,JSON_UNESCAPED_SLASHES);

here is my php codeigniter model code.

class Groups_Model extends CI_Model
   public function groupmemberlist($session_id)
        $where = "sender_id='".$session_id." AND request_status=1 ' OR receiver_id='".$session_id."' AND request_status=1";
        $query =$this->db->get();
        foreach($query->result_array() as $row)

        return $data;
   function friendlist($userid)
      return $query->result_array();

this is how I am getting the response in android.

        "user_id": "7",
        "auth_id": "109236658041750871608",
        "full_name": "Abdullah Khaled",

        "email_id": "abdullahkhaled604@gmail.com",

        "image_url": "https:\/\/lh5.googleusercontent.com\/-G9ZMVsph4no\/AAAAAAAAAAI\/AAAAAAAAAAA\/ACSILjX8pu4sXdCmwpUrFTgcRjXT4iwD-w\/s96-c\/photo.jpg"

and after getting this response activity get closed.

I have also tried in android side to replace the backslash but it not worked for me.

below code i have tried to replace the backslash in android.

String myUrl = json_date.getString("image_url");
        //myUrl = myUrl.replaceAll("\\\\", "");

I get stucked in from two days so please help. thanks in advance.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301561 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO