Parsing JSON in BAS
The JSON module in Browser Automation Studio — read and modify JSON with JSONPath, the right tool for API responses and structured data the HTTP client returns.
When data comes back as JSON rather than a rendered page — from an API, an XHR call, or the HTTP client — the right tool isn’t XPath, it’s the JSON module. It reads and reshapes JSON using JSONPath, the JSON equivalent of an XPath query.
What it’s for
The JSON module works with JSON data through JSONPath expressions. Where XPath addresses elements in HTML, JSONPath addresses values in a JSON document — you write a path to the field you want and the module returns it. This is how you pull structured data out of API and HTTP-client responses cleanly.
The actions
Reading.
- Get value — return a single value at a JSONPath.
- Get all values — return every value matching a path.
- Get slice — read an array or a portion of one.
- Count elements — how many items an array holds.
Modifying.
- Change value — set a value at a path.
- Delete value — remove a value.
- Change format — reformat the JSON.
Validating.
- Is suitable for JSONPath — check whether a path resolves before relying on it.
Where it fits
JSON parsing is the natural partner of the HTTP client. A common pattern: send a request to an API, get a JSON body back, then use Get value and Get all values with JSONPath to extract the fields you need — far faster and cleaner than scraping a rendered page. Use XPath for HTML, JSON for APIs, and you’ve covered the two ways structured data reaches your bot.
FAQ
How do I parse an API response in BAS?
Use the JSON module. It reads JSON with JSONPath expressions — get a single value, get all values, read a slice or array, and count elements — which is exactly how you extract fields from an API or HTTP-client response.
What is JSONPath in BAS?
JSONPath is the query language the JSON module uses to address parts of a JSON document, similar to how XPath addresses HTML. You write a path to the value you want and the module returns it.
- Browser Automation Studio: The Complete Practical GuideGuide
- Building Your First Bot in Browser Automation StudioA step-by-step walkthrough of creating your first working BAS bot — from a blank project to a flow that navigates, extracts data, and runs in multiple threads.
- Setting Up Proxies in Browser Automation StudioHow to configure proxies in BAS the right way — proxy types, per-thread assignment, rotation, and the checks that keep multi-account bots from getting flagged.
- Finding Elements in BAS: Selectors That Don't BreakHow element search works in Browser Automation Studio — CSS vs XPath selectors, why recorded ones break, and how to write selectors that survive page changes.