如何从Json Path Post Processor中提取值?

时间:2016-11-21 04:23:00

标签: json regex jmeter

我需要提取 id ,其中 asOf :2016-11进行最新一次运行。

例如,下面给出请求的响应我需要将21aa83fe-fe1b-4447-9b2e-05e7d6cd67d3存储在一个变量中,因为截至2016年是最后一个而且相应的id是。你能告诉我如何编写JSON Path Post Processor Expression吗?

{"id":"1fabbb02-0b7d-4bec-badd-9fe9f1c63f08","batch" {"id":"GL1600"},"asOf":"2014-06-16T00:00:00Z","version":3,"statusIdentifier":"END"},
{"id":"212fc2b5-03d6-4d76-ab6d-e9e783459120","batch":{"id":"N1400"},"asOf":"2014-06-16T00:00:00Z","version":3,"statusIdentifier":"END"},
{"id":"21aa83fe-fe1b-4447-9b2e-05e7d6cd67d3","batch":{"id":"N1500"},"asOf":"2016-11-16T00:00:00Z","version":3,"statusIdentifier":"END"}, 

1 个答案:

答案 0 :(得分:1)

如果您的回复是有效的JSON,则可以使用==过滤器运算符,如

$..[?(@.asOf == '2016-11-16T00:00:00Z')].id

参考文献:

如果响应无效JSON,则需要转到Regular Expression Extractor