Calling a REST API with JMeter 3.3, I have following JSON response:
{"map":{},"meta":{"code":"123"}} How can I extract the value of code (123)?
So far I am using this:
- Thread Group
- HTTP Request
- JSON Extractor
with this 2 vars: code; meta and this json path expressions: $.code; $.meta
- JSR223 Assertion
with this Groovy code:
String codeString = vars.get("code"); String meta = vars.get("meta"); log.info ("The code answer is " + codeString); if (codeString != "000"){ AssertionResult.setFailureMessage("The code is: " + codeString + " - meta is: " + meta); AssertionResult.setFailure(true); } this is the assertion result instead:
Assertion error: false Assertion failure: true Assertion failure message: The code is: No_Default - meta is: {"code":"000"}