I am trying to send the following parameters to a server through HTTP POST:
["my_session_id","{this=that, foo=bar}"]
But the server is returning a parse error because of the quotes around the hash.
I am trying to remove them with a regex like so:
params.replaceAll("\\\"\\{", "\\{");
params.replaceAll("\\\"\\}", "\\}");
In all honestly I have no idea what I’m doing. Please help.
Thanks in advance!
There’s two issues here: First, you’re not re-assigning the string.
Strings are immutable in Java (cannot be changed), so you must assign the result. Second, you’re replacing"}instead of}".Here’s what I used:
Which prints out:
PS: Bit of advice, use JSON. Android has excellent JSON handling, and it is supported in PHP as well.