I'm using asp.net web api as the server and android as the client. I'm requesting from android to web api and i'm getting json string.When i assign this json string to java object using Gson i'm getting exception.My code is,
private StringBuilder inputStreamToString(InputStream is) {
String line = "";
StringBuilder total = new StringBuilder();
// Wrap a BufferedReader around the InputStream
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
// Read response until the end
try {
while ((line = rd.readLine()) != null) {
total.append(line);
}
Log.i("RETURN DATA:", total.toString());
Gson gson = new Gson();
ReturnData returndata = (ReturnData)
gson.fromJson( total.toString(), ReturnData.class);
Log.i("RESULT DATA", returndata.ResultData.toString());
} catch (IOException e) {
e.printStackTrace();
}
// Return full string
return total;
}
And my json string(I'm getting from server) like,
"\"OperationResult\":0,\"Messages\":operationsuccess\"\",\"UpdateAvailable\":\"\",\"ResultData\":{\"SessionId\":1584789522,\"UserName\":vinoth,\"AccoundId\":1236985,\"Roles\":[],\"DisplayName\":Vinoth,\"Status\":0,\"Type\":0}}"
