Jmeter:&を抽出する方法BeanShellプリプロセッサを使用してレスポンスからaccountIDを変数に格納しますか?このためにJSONや正規表現を使用できますか?Jmeter:BeanShellプリプロセッサでJSON応答を解析し、変数に格納する
私の回答のように見えるものをいくつか:
{
"address":{
"street1":"6550 Vallejo Street",
"street2":"",
"city":"Emeryville",
"state":"CA",
"zipcode":"98456",
"country":"Uk"
},
"timezone":"US/Pacific-New",
"reference":"fe_qa001",
"token":"ns7h4rqVZegSZG6yZls6",
"login":"[email protected]",
"accountId":-9223372036762408565,
"firstName":"qa029",
"lastName":"svcqa",
"email":"[email protected]",
"component":[
{
"type":1,
"reference":"12-1",
"version":"1",
"base":"Plastic",
"zipcode":"94556",
"bedsize":"high",
"bed":false,
"componentId":0,
"code":"P5",
"sku":"abcd",
"serial":"1234",
"purchaseDate":1372723200000,
"chamber":2
}
]
}
私はJMeterのに初心者です。それで誰も私をここで助けることができます。要件は、下記の応答からアカウントIDを厳密にし、BeanShellプリプロセッサを使用して変数に格納するようなものです。
私は、次のコードを試みたが、それは動作しません: 関連の構成は次のようになりますString jsonString = prev.getResponseDataAsString(); JsonObject accountId = JsonObject.readFrom(jsonString); JsonArray accountId = accountId.get(1).asObject()。get( "accountId")。asString(); vars.put( "accountId_BSH"、accountId); –