Получение следующего исключения в загрузочном сервере Spring:
Ошибка синтаксического анализа JSON: ожидал нераспознанный токен ('true', 'false' или 'null'); вложенным исключением является com.fasterxml.jackson.core.JsonParseException
при получении запроса POST от Volley-android в Spring Rest Controller
public class RegistrationCredential {
@NotEmpty(message = "MacId is mandatory")
@JsonProperty("macId")
private String macId;
@NotEmpty(message = "Mobile number is mandatory")
@JsonProperty("mobileNo")
private String mobileNo;
....
}
Добавлен тег @JsonProperty ("name") в модели
@PostMapping(consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE})
public ResponseEntity<String> vendorMobileRegistration(@Valid @RequestBody final RegistrationCredential credential) {}
Выдержка из реализации залпа:
StringRequest stringRequest = new StringRequest(Request.Method.POST, SpotPollingURLs.REGISTRATION_URL, new Response.Listener <String>() {
@Override
public void onResponse(String response) {
System.out.println("Getting response frome url --- "+response);
try {
JSONObject jsonObject = new JSONObject(response);
String status = jsonObject.getString("status");
String messageCode = jsonObject.getString("MessageCode");
String message = jsonObject.getString("message");
if (status.equals("success") && messageCode.equals("MOBILE_REGISTERED_SUCCESSFULLY")) {
sendOTP(mobile, "send");
customDalog(mobile);
} else if (status.equals("success") && messageCode.equals("MOBILE_NUMBER_ALREADY_REGISTERED")) {
new CustomToast().showToast(getContext(), view, message);
} else if (status.equals("error")) {
new CustomToast().showToast(getContext(), view, message);
} else {
new CustomToast().showToast(getContext(), view, "Something went wrong check your connection");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
System.out.println("Getting error -- "+error);
progressBar.setVisibility(View.GONE);
}
}){
@Override
public Map <String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
return headers;
}
@Override
protected Map <String, String> getParams() throws AuthFailureError {
HashMap<String, String> params = new HashMap<>();
params.put("mobileNo", mobile);
params.put("macId", uniqueId);
return params;
}
};