I Having The Two Json Response From The Server Side With The Same "key".the Json Is Posted Below
{'data': { 'userId':'+919923911289', 'inTime':'2016-07-25 12:09:47+05:30', 'outTime':'0', 'totalTime':'0', 'type':'at
Solution 1:
Create a another model
classErrorModel{
String data;
}
and in your main method:
try{
GsonModel model = gson.fromJson(response,GsonModel.class);
// ...
}catch(JsonSyntaxException e){
ErrorModel model = gson.fromJson(response,ErrorModel.class);
// show error
}
Solution 2:
if (data.equalsIgnoreCase("please try again...") {
//show error
} else {
//do your work with response
}
Solution 3:
if(data.has("userId") && !data.isNull("userId") ){
String user_Id=data.getString("userId");
}else{
////show message "please try again..." here....
}
Post a Comment for "I Having The Two Json Response From The Server Side With The Same "key".the Json Is Posted Below"