JSON报错 SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data

JSON报错 SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data_第1张图片

String jsonRedirect = "{code:-101, msg:'没操作权限'}";//这里有错
response.setContentType("application/json; charset=utf-8");
response.getWriter().println(jsonRedirect 
);

解决:改用双引号

String jsonRedirect = "{\"code\":-101, \"msg\":\"没操作权限\"}";

你可能感兴趣的:(jsp)