I had a scenario where I need to give back slash for a key in JSON put method like below
json.put("path" , " \\abx\2010\341\test.PDF");
The value I gave for path key shows error.
How to handle this case?
I had a scenario where I need to give back slash for a key in JSON put method like below
json.put("path" , " \\abx\2010\341\test.PDF");
The value I gave for path key shows error.
How to handle this case?
You need to write double slash instead of one: \\
So your code become:
json.put("path" , " \\\\abx\\2010\\341\\test.PDF");
You can learn more about escaping special characters in this answer.
You need to escape \
.
Try json.put("path" , " \\abx\\2010\\341\\test.PDF");
You can learn more about it under Escape Sequences.
double \\ = single \ in string ""
json.put("path","\\abx\\2010\\341\\test.PDF");
If you want to show like this, JSON file should be as below.
"path" : " \\abx\2010\341\test.PDF"
JSON also \ represent as \ in java special characters. Then java code should be as below.
json.put("path" , " \\\\abx\\2010\\341\\test.PDF");