This problem is encountered in spring MVC and JSP simulating asynchronous requests of Ajax.
Complete error message:
JSON parse error: Unexpected character (''' (code 39)): was expecting double-quote to start field name; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character (''' (code 39)): was expecting double-quote to start field name
Error reason: the format of JSON in the front-end Ajax request is incorrect. The outer part of the array should be wrapped in single quotation marks, and the inner key & amp; Value pairs are enclosed in double quotes.
As shown below.
$.ajax(
{
url:"testAjax",
contentType:"application/json;charset=UTF-8",
//Right
data:'{"username":"zs","password":"12456","age":"18"}',
//Wrong
data:"{'username':'zs','password':'12456','age':'18'}",
dataType:"json",
type:"post",
success:function (data) {
// data is the server-side response data
alert(data);
alert(data.username)
}
}
Read More:
- [Solved] JSON parse error: Unexpected character (‘‘‘ (code 39)): was expecting double-quote to star
- [Solved] SyntaxError:JSON.parse:unexpected character at line 1 column 1 of the JSON data
- PHP Parse error: syntax error, unexpected ‘class‘ (T_CLASS), expecting identifier (T_STRING)
- [Solved] Interface automation test: JSON parse error
- JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token
- [Solved] Parsing JSON error unexpected end of JSON input
- Redis cannot double-click redis-server.exe to start normally
- How to parse JSON string in.Net [error reading job object from jsonreader. Current jsonreader item is not an obj]
- [Solved] Error: Waveform5.vwf.vt(30): near “1“: syntax error, unexpected INTEGER NUMBER, expecting ‘)‘ Erro
- Syntaxerror: unexpected end of JSON input [How to Solve]
- [Solved] SyntaxError: Unexpected end of JSON input
- Template cannot be rendered due to the joint query of populate in mongoose: syntax error: unexpected token r in JSON at position 0
- JSON parse error: raw timestamp (1595952000000) not allowed for
- vue VM682:1 Uncaught SyntaxError: Unexpected token u in JSON at position 0
- Error: (list) object cannot be coerced to type ‘double’
- There was an unexpected error (type=Method Not Allowed, status=405). Request
- [Error] invalid operands to binary ^ (have ‘double‘ and ‘float‘)
- Springboot Error: There was an unexpected error (type = internal server error, status = 500)
- Json: struct field readyReplicas has json tag but is not exported [How to Solve]
- [Solved] ENSP Failed to Start AR Device error code: 40