Skip to content Skip to sidebar Skip to footer

How To Remove Escape Slash From String In Android

I have tried all possible solution but couldn't find any answers. I have following string. '{\'property_type\':[\'residential\'],\'status\':[\'active\'],\'category\':[\'sale\'],\'p

Solution 1:

myString.replaceAll("\\/","");

Solution 2:

$postdata = stripslashes("[".$_POST["data"]."]");
$data = json_decode($postdata,true);
try{
if(is_array($data)){
    foreach ($dataas$row) {
        $line1 = $row['line1'];
        $line2 = $row['line2'];
        $line3 = $row['line3'];
        $line4 = $row['line4'];
    }
}
}catch(Exception$e){

}

here i am passing the data from my android app to my server and decode the values using the above code successfully

hope it helps to you...

Solution 3:

You may try this if you want to remove escape slash from android ....

String receivedString ="{\"property_type\":[\"residential\"],\"status\":[\"active\"],\"category\":[\"sale\"],\"page_size\":8,\"cur_page\":1}";

    String changedString = receivedString.replaceAll("\"", "\"");
    Log.d("your_tag", changedString);

Output will be like below :

{"property_type":["residential"],"status":["active"],"category":["sale"],"page_size":8,"cur_page":1}

Solution 4:

yesss finally this works for me :

//delete backslashes ( \ ) :data = data.replaceAll("[\\\\]{1}[\"]{1}","\"");
//delete first and last double quotation ( " ) :data = data.substring(data.indexOf("{"),data.lastIndexOf("}")+1);
            JSONObject json = new JSONObject(data);

Post a Comment for "How To Remove Escape Slash From String In Android"