Jmeter「第六节」-json返回结果处理

直接上代码吧

import org.json.*;

String response_data = prev.getResponseDataAsString();

JSONObject data_obj = new JSONObject(response_data);

String apps_str = data_obj.get("faces").toString();

JSONArray apps_array = new JSONArray(apps_str);

String[] result = new String[apps_array.length()];

String[] result2 = new String[apps_array.length()];

//System.out.println(apps_array.length());

for(int i=0;i

JSONObject app_obj = new JSONObject(apps_array.get(i).toString());

String name = app_obj.get("score").toString();

String name2 = app_obj.get("userId").toString();

result[i] = name;

result2[i] = name2;

}

vars.put("score2", Arrays.toString(result));

vars.put("userId2", Arrays.toString(result2));

System.out.println("score2 :"+ Arrays.toString(result));

System.out.println("userId2 :"+ Arrays.toString(result2));

json返回结果处理 引用了一个第三方的json.jar包

需要的同学如果网上找不到,可以私信哈

你可能感兴趣的:(Jmeter「第六节」-json返回结果处理)