Passing JSON via URI
I am trying to create a REST based web service with data encapsulated using JSON. My problem is that when I pass a string version of JSON in a URI, it accesses something like this:% 7B% 22coal% 22: 100,% 22ele% 22: 1500.1% 7D.
I'm wondering if there are any Java functions to convert between escaped and unescaped versions so that I can parse the string.
a source to share
This will be URLDecoder . But unless you are doing something wrong, you should not use it, since methods in the Servlet API pass already decoded strings.
a source to share
You don't have to decode the URL-escaped text, the web server does it by itself, it should be completely transparent to you.
As some people have already pointed out, you are using URLDecode to reverse the URL bar
If at some point in your code you are manually avoiding the JSON string that is probably the problem since getting it is encoded 2 times.
a source to share