JMeter报JSONObject not found in namespace

时间:2024-03-23 13:21:43

当JMeter运行时报Typed variable declaration : Class: JSONObject not found in namespace,是因为${JMETER}\lib\下缺少json.jar包,下载链接如下:
https://pan.baidu.com/s/1KFDUIq40BhUXcy2NYo7YkA 密码: c91m
http://www.downcc.com/soft/17593.html
JMeter报JSONObject not found in namespace

【验证思路】

①获取请求的返回值,即Json响应;

String response_data = prev.getResponseDataAsString(); //注意此处获取到的是String类型;

②利用上一步获取的字符串形式的JSON,结合Java处理Json的方法,将需要的键值提取出来;

需要利用JSONObject或者JSONArray构造JSON对象。

JSONObject JsonData = new JSONObject(StrData);