一次 JMeter 脚本请求错误 Could not read JSON Unexpected character
用 Badboy 录制的脚本,有个界面是 Ajax 提交表单,先有 HTTP Status 415 错误(解决方案参考《一次 JMeter 脚本请求错误 HTTP Status 415 的解决笔记》),然后又有 Could not read JSON: Unexpected character ('%' (code 37)): expected a valid value 错误。监听器 "察看结果树" 可以看到服务器响应数据如下:
{"status":0,"data":"Could not read JSON: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [email protected]; line: 1, column: 2]; nested exception is org.codehaus.jackson.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [email protected]; line: 1, column: 2]"}
该次 http 请求如下图所示:

另外监听器捕捉到该次请求如下所示:
POST http://xxx.com/merServPlat/proc/modifySubmit.json
POST data:
%7B%22stageId%22%3A276%2C%22modifyTime%22%3Anull%2C%22merId%22%3A276%2C%22merCode%22%3A%22000100015200001%22%2C...
POST data 里只有这些。这些明显是一个 json 串,只不过 JMeter 竟然把 json 串转义后再提交了。
修改该次 HTTP 请求的 Body Data,把要提交的 json 串考进去,保存,重新运行测试,问题解决。
{"status":0,"data":"Could not read JSON: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [email protected]; line: 1, column: 2]; nested exception is org.codehaus.jackson.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [email protected]; line: 1, column: 2]"}
该次 http 请求如下图所示:
另外监听器捕捉到该次请求如下所示:
POST http://xxx.com/merServPlat/proc/modifySubmit.json
POST data:
%7B%22stageId%22%3A276%2C%22modifyTime%22%3Anull%2C%22merId%22%3A276%2C%22merCode%22%3A%22000100015200001%22%2C...
POST data 里只有这些。这些明显是一个 json 串,只不过 JMeter 竟然把 json 串转义后再提交了。
修改该次 HTTP 请求的 Body Data,把要提交的 json 串考进去,保存,重新运行测试,问题解决。
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.****.net/jiangjunshow