public class DslJsonExtractor extends DslVariableExtractor<DslJsonExtractor>
By default, the JMESPath is configured to extract from the main sample (does not include sub samples) response body the first match of the JMESPath. If no match is found, then variable will be assigned empty string.
| Modifier and Type | Class and Description |
|---|---|
static class |
DslJsonExtractor.CodeBuilder |
DslScopedTestElement.Scope, DslScopedTestElement.ScopedTestElementCallBuilder<T extends org.apache.jmeter.testelement.TestElement>| Modifier and Type | Field and Description |
|---|---|
protected String |
jmesPath |
defaultValue, matchNumber, varNamescope, scopeVariableguiClass, name| Constructor and Description |
|---|
DslJsonExtractor(String varName,
String jmesPath) |
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.jmeter.testelement.TestElement |
buildTestElement() |
DslJsonExtractor |
defaultValue(String defaultValue)
Sets the default value to be stored in the JMeter variable when no match is found.
|
DslJsonExtractor |
matchNumber(int matchNumber)
Sets the match number to be extracted.
|
scope, scopeVariable, setScopeTobuildConfiguredTestElement, buildTestElementGui, buildTreeUnder, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGuiclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildTreeUnder, showInGuiprotected String jmesPath
public DslJsonExtractor matchNumber(int matchNumber)
For example, if a response looks like this: [{"name":"test"},{"name":"tester"}]
and you use [].name as JMESPath, first match (1) would extract test and second
match (2) would extract tester.
When not specified, the first match will be used. When 0 is specified, a random match will be
used. When negative, all the matches are extracted to variables with name <variableName>_<matchNumber>, the number of matches is stored in <variableName>_matchNr, and default value is assigned to <variableName>.
matchNumber - specifies the match number to use.public DslJsonExtractor defaultValue(String defaultValue)
When match number is negative then the value is always assigned to the variable name.
A common pattern is to specify this value to a known value (e.g.: <VAR>_EXTRACTION_FAILURE) and then add some assertion on the variable to mark request as failure when the match doesn't work.
When not specified, then the variable will be assigned to empty string.
defaultValue - specifies the default value to be used.protected org.apache.jmeter.testelement.TestElement buildTestElement()
buildTestElement in class BaseTestElementCopyright © 2023. All rights reserved.