Jmeter JSON EXtractor

时间:2018-04-13 00:02:11

标签: jmeter

在发出HTTP请求后的Jmeter中,我有一个类似下面的JSON响应数据,我想得到所有accountId的列表。

{"firstPage":"http://192.168.30.98/XX/v3.0/accounts?pageno=1","lastPage":"http://192.168.30.98/XX/v3.0/accounts?pageno=36","nextPage":"http://192.168.30.98/XX/v3.0/accounts?pageno=2","previousPage":null,"results":[{"accountId":220,"name":"abc2","url":"http://192.168.30.98/XX/v3.0/accounts/220"},{"accountId":1,"name":"ZZ1","url":"http://192.168.30.98/XX/v3.0/accounts/1"},{"accountId":7,"name":"ZZ2018-03-28T22:18:55.393Z","url":"http://192.168.30.98/XX/v3.0/accounts/7"},{"accountId":8,"name":"ZZ2018-03-28T22:23:11.081Z","url":"http://192.168.30.98/XX/v3.0/accounts/8"},{"accountId":9,"name":"ZZ2018-03-28T22:27:54.129Z","url":"http://192.168.30.98/XX/v3.0/accounts/9"},{"accountId":10,"name":"ZZ2018-03-....................}

我看到JSON Extractor可以帮助我,所以我在HTTP请求后添加了它。树:

Names of created variables: = accoutnId

JSON Path expression = $..accountId

Match No: -1

compute .. = checked

当我在View Result Tree中运行测试时,我仍然会看到上面的列表,我看不到任何内容,accountId_1accountId_2

所以我想也许是因为我没有JSON插件,我去了,Options --> Plugin Manager --> Available Plugins然后我发现JSON plugins (deprecated)我安装了它

重启Jmeter

重新进行测试

但我仍然没有看到JSON提取的accountIds?

1 个答案:

答案 0 :(得分:0)

这里

Names of created variables: = accoutnId

可能会有一些拼写错误,因为您要求" accountId_1 ..或accountId_2"。 " accoutnId"中存在拼写错误。和" accountId_1"。

参考下图

Json Extractor

Json Parmater for exracting single value