在Jmeter中,我试图从json中提取值。这是我收到的json 响应:
{ Definition: { key: 1124, Id: 1743, srcID: "3427", pcKey: -1, userName: "abraizada", cName: "JMeter2016-11-27-1480283993838", Type: "SUBJECT", cohortTool: "Web app", cCount: 74, extractionStatus: "Completed", dateCreated: "2017-05-09T18:35:35Z" }, datasource: { id: 2, name: "Claims-OMOP", subjectCount: 116352 }, project: { id: 747, name: "Jmeter Project" } }, { cohortDefinition: { key: 1123, Id: 1742, srcID: "3447", pcKey: -1, userName: "IE_USER", cName: "JMeter2016-11-15-1479204865900", Type: "SUBJECT", cohortTool: "Web app", cCount: 74, extractionStatus: "", dateCreated: "2017-05-09T18:35:35Z" }, datasource: { id: 2, name: "External", sCount: 116352 }, project: { id: 747, name: "Jmeter Project" } },
从上面的响应中,如果srcID = 3447,我想提取值’key’。我试图做这个$ .. cohortKey [?(@。srcCohortId = 3447)]。cohortKey
但没有得到结果。谁能帮助我根据 条件提取“关键”价值。
您可以使用JSON Extractor 对JSON Path表达式执行以下操作:
$..[?(@.srcID==3447)].key
where:
..
[]
?( )
@
@.srcID==3447
.key
我举一个例子,并像上面一样配置JSON Extractor
And the result
有关JSON提取器的更多用法,请参考: