res() as a function to read values from the HTTP response body of the request you just sent. It works in vars, assertions, scripts, and tests.
You do not need to assign the body to a variable first. Bruno already has it. res('customer.address.city') is like a safer nested get on that body (similar to lodash.get()).
Response query filtering (including
[?] with filter functions and object predicates) works in both Safe Mode and Developer Mode.Sample response body
All examples below assume JSON returned (for example fromhttps://echo.usebruno.com or your own API):
Query cheat sheet
Query styles
Dot notation
Walk the object path. When a step is an array, Bruno collects matching values from every element:Deep navigation (..)
Skip intermediate keys and find a property anywhere under the body:
Array indexing
Pick one element by index ([0] is the first):
Filter with a function
[?] keeps items where the function returns true. The argument is each object in that array:
Filter with an object predicate
Match items by property equality (same as checking each field with===):
Map with a function
If the function returns a non-boolean value, Bruno treats it as a mapper:Common mistakes
- Do not wrap the sample JSON in
const data = { ... }and expectres()to read that variable.res()always reads the live response body. - Prefer
res('path')for nested gets. Useres.getBody()when you need the whole object or normal JavaScript property access: