0
我已經使用beanshell腳本解碼了一個響應並將其保存在一個XML文件中。需要從Json文件發送一個屬性作爲http請求的輸入
BeanShell的後置處理程序腳本
import org.apache.commons.io.FileUtils;
import org.apache.commons.codec.binary.Base64;
String response= vars.get("data");
vars.put("response",new String(Base64.decodeBase64(response)));
Output = vars.get("response");
f = new FileOutputStream("E:/JMeter/apache-jmeter-3.1/bin/response.xml");
p = new PrintStream(f);
this.interpreter.setOut(p);
print(Output);
f.close();
響應
{
"Username": "[email protected]",
"UserCreateDate": "2017-02-23T04:02:59.123Z",
"UserLastModifiedDate": "2017-02-23T04:04:50.695Z",
"Enabled": true,
"UserStatus": "CONFIRMED",
"sub": "50e0dff7-0342-40f1-b793-68de404d95c4",
"_app": "586cc7cc851dc874ac59f001",
"email_verified": "true",
"_org": "58adbaf2ffc4de735f1fbe28",
"name": "Raghu Ram kota",
"_groups": [
{
"_id": "58adbaf2ffc4de735f1fbe29",
"name": "default",
"slug": "default",
"description": "Default Group",
"id": "58adbaf2ffc4de735f1fbe29"
}
],
"_roles": [
{
"_id": "58adbaf2ffc4de735f1fbe2a",
"name": "ADMIN",
"slug": "admin",
"description": "ADMIN Role",
"id": "58adbaf2ffc4de735f1fbe2a"
}
],
"permissions": {
"listen": {
"DELETE": false,
"READ": true,
"UPDATE": false,
"CREATE": false
},
"profile": {
"STOPLISTEN": true,
"STARTLISTEN": true,
"AUTHORIZE": true,
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
},
"post": {
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
},
"group": {
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
},
"user": {
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
}
},
"email": "[email protected]",
"meta": {},
"isAdmin": "false",
"iat": 1487919175,
"exp": 1487926375
}
現在我需要只發送_org價值,這是強調,作爲輸入到另一個HTTP請求。有什麼建議麼?
謝謝,但我們怎麼能發送這個作爲輸入到另一個http請求。我用vars.put(「CompId」,json_org)替換了log.info(json_org),並將其作爲$ {CompId}在另一個hhtp請求中使用。我錯過了什麼。 –
只需將其存儲到像vars.put(「org」,json._org)這樣的JMeter變量中,稍後根據需要將其引用爲「$ {org}」 –
謝謝。它的工作現在。 –