Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Quote Doesnt working while pass data to json in android

I am working on application in which I need to pass all the data send to server via json array at exact user had passed.

But My problem is When I pass Single quote message doesn't send to server.

I had tried.

text=text.replaceAll("'","\'");

But My problem is

  1. When user press single quote message doesn't send.
  2. When user press single quote two time only one single quote is send.

Please give solution for that.

like image 502
Pooja Roy Avatar asked Mar 26 '26 01:03

Pooja Roy


1 Answers

Change your replaceAll("'","\'"); to replaceAll("'","\\u0027");

EDIT:

\u0027 is the unicode representation of '. Except in rare cases, unicode representations can be used in place of troublesome characters like ',",@,?, and &.

You are likely losing your single quote characters because your json is going through multiple layers of serialization/deserialization that are outside your control.

like image 151
4mnes7y Avatar answered Mar 28 '26 16:03

4mnes7y



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!