问题
My jmeter
application sends a request and expects the following json
in the response.
{"external-profile":{"email":"myemail@gmail.com","firstname":"fn","lastname":"ln","portfolio":{"field1":[],"field2":[],"field3":[]}}}
field1
, field2
and field3
could be empty arrays or might have some value. Is there a way to check that the message has field1,2,3
but ignore the value?
I tried doing this but it doesn't work - {"external-profile":{"email":"myemail@gmail.com","firstname":"fn","lastname":"ln","portfolio":{"field1":[\.*],"field2":[\.*],"field3":[\.*]}}}
. To be honest, I don't know if this is the right way to specify regular expressions in jmeter
.
回答1:
Since JMeter 5.2 you have JSON JMESPath Assertion which provides keys function, using it you can validate the attributes names, example configuration:
And textual representations for easier copying and pasting:
- JMESPath:
join(',',keys("external-profile".portfolio))
- Expected value:
field1,field2,field3
However it will fail if the order of "fields" will be different so you might want to go for JSON Schema Validator instead, it can be used from JSR223 Assertion
来源:https://stackoverflow.com/questions/65149040/is-it-possible-to-use-wild-cards-in-json-validation-or-ignore-some-values-in-jso