Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
During Login time i got this error, please don't downgrade this if you know any solution please guide me. I also checked different stack overflow post but they all are talking about trim the string or other solution with retrofit but i can't solve it. I use volley.
My Json File:-
"error": false,
"user": [
"user_id": "123",
"customer_name": "Abc",
"email": "abc@example.com",
"salt": "123abc",
"phone": "1234567890",
"address": "Enter Address",
"postal_code": "1234"
This is my Java Class :-
@Override
protected String doInBackground(Boolean... booleen) {
ExampleApi exampleApi = new ExampleApi();
LoginUser result;
try {
result = exampleApi.loginPost(sharedPreferences.getString("abc_id", ""), semail, fcmToken, spassword);
Gson gson = new Gson();
String json = gson.toJson(result);
JSONObject jObj = new JSONObject(json);
Log.e("result1", String.valueOf(jObj));
if (jObj.getString("error").equalsIgnoreCase("false")) {
JSONArray jsonArray = jObj.getJSONArray("user");
JSONObject jsonObject1 = jsonArray.getJSONObject(0);
return "true";
}else {
String errormsg = jObj.getString("error_msg");
return errormsg;
} catch (ApiException e) {
e.printStackTrace();
Log.e("error", e.toString());
} catch (JSONException e) {
e.printStackTrace();
–
–
–
Check whether the properties of user
object (user_id, customer_name. etc
) are in correct format which is equal to the object received as response.
ps: If user_id
is an Integer
in your user
object also it should be an Integer
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.