Testing / Apache JMeter Interview questions
Which is better for extracting dynamic values: Regular Expression Extractor or JSON Extractor, and why?
For a JSON API response specifically, the JSON Extractor is generally the better choice, since it navigates the response using JSONPath expressions against the response's actual structure, which is more robust to minor formatting changes (whitespace, key ordering) than a regex pattern matching against the raw text.
The Regular Expression Extractor remains the better, and sometimes only practical, choice for non-JSON responses - plain text, HTML, or any format without a structured parser extractor available - or for JSON responses where you specifically need to extract based on a text pattern that doesn't map cleanly onto the document's structural hierarchy.
Performance is a secondary consideration worth knowing but rarely decisive: a JSON Extractor genuinely parsing the document structure carries somewhat more overhead per extraction than a regex match, but for realistic response sizes this difference is generally small compared to the robustness and maintainability benefit of matching against actual structure for JSON responses.
In practice, many test plans use both, since a JSON Extractor for JSON API responses and a Regular Expression Extractor for the exceptional cases it doesn't cleanly handle - like values embedded in non-JSON headers or logs - complement rather than exclude each other, so the real question is usually response format on a case-by-case basis, not a single blanket rule for the whole test plan.
More Related questions...
