I have been successfully using fromJson function in Android for many different types of objects including String. But for the first time the returned object is a URL string and this seems to pose problem. Here is the code I use:
Gson gson = new Gson();
JSONObject jsonObj = new JSONObject(responseString);
String returnedLink = gson.fromJson(jsonObj.getJSONObject("data").getString("getUrl"), String.class);
If the responseString is in the form
{"data":{"getUrl":"https://domain.com/folder/something"}}
I get a MalformedJsonException.
If I set responseString to
{"data":{"getUrl":"httpsdomain.com.folder.something"}}
returnLink is correctly set to "httpsdomain.com.folder.something"
It looks like if the deserializer was trying to decode the url string and got confused.
Any hint, anyone ?