Reputation: 449
I am sending json object to server, My url having json object.Json object having special characters,how to encoding special characters in android, please help me.Thanks in advance.
Upvotes: 0
Views: 3027
Reputation: 6647
If I understood you, you want to send a json object using the url itself (that is, as a parameter). If security doesn't matter you (it will be visible), you could just encode using [Base64][1]
.
You should probably play with your json
object to convert it to a byte[]
, called jsonbytes
, for instance, then use Base64.encodeToString(jsonbytes, Base64.URL_SAFE)
and sending this as a parameter.
Your server then should convert this Base64 encoded string into a json object, which tends to be straightforward if you're using PHP:
$jsonString = base64_decode($_GET['json']);
$json = json_decode($jsonString, TRUE);
This will give you an associative array in PHP. If you just want the json string, skip the last step.
Upvotes: 0