我正在使用JMeter进行负载测试,每个API均以Json格式给出响应。我需要特定行(特定行)以CSV格式导出。
例如->这是The Json Response
{
"success": true,
"data": [
{
"alert_id": "-1",
"description": "Get Manager info",
"input": "{"task_tag":"ad_manager_info","inputfields":[],"tenantcode":"rtech","token":"6wdd68-9d15-46b7-641c-9595ewsd5wedsd-1554717635279","isdemo":false}",
"is_evidence": "n",
"logo_path": "lib/log/abc.png",
"name": "Get Manager Info",
"processed": "y",
"readstatus": "n",
"requestid": "2118",
"requesttime": "1554717797.07432",
"response": {
"success": true,
"data": {
"@odata.context": "https: //graph.microsoft.com/v1.0/$metadata#directoryObjects/$entity",
"@odata.type": "#microsoft.graph.user",
"id": "bdg12-1257-XXXX-XXXX-4a8656b00171",
"businessPhones": [
],
"displayName": "MIC",
"givenName": "MIC",
"jobTitle": "Senior",
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "JANY",
"userPrincipalName": "ABC@YAHoo.onmicrosoft.com"
},
"error": "",
"status": "completed",
"errorpath": "",
"displaymessage": "",
"sessionexpired": false
},
"responseid": "2119",
"responsetime": "1554717802.52754",
"task_handler": "ActiveDirectory",
"tasktag": "ad_manager_info",
"username": "ScottMcCall"
},
]
我只需要“描述”“响应时间”。
这是我正在使用的代码
var a = ctx.getPreviousResult().getResponseDataAsString();
log.info("Value of A is --> " + a);
log.info("Value of Resposne is -->" + IDvalue)
f = new FileOutputStream("E:/Result.csv");
p = new PrintStream(f);
FileWriter fr = new FileWriter("E:/Result.csv", true);
String b = a.description
log.info("Value of B is " + b)