name = JSON Response Capture Examples
description = Demonstrates direct, nested, indexed, defaulted, and dependency-based JSON response captures using JSONPlaceholder.
$ BASE = https://jsonplaceholder.typicode.com
---
Get User
GET {{ BASE }}/users/1
& body.id -> $USER_ID
& body.username -> $USERNAME
& body.address.city -> $CITY
& body.address.geo.lat -> $LATITUDE
& body.company.name -> $COMPANY_NAME
& body.address.country -> $COUNTRY := unknown
# User request succeeds
^ & status == 200
# Captures the user id
^ $USER_ID == '1'
# Captures the username
^ $USERNAME != ''
# Captures the city
^ $CITY != ''
# Captures the latitude
^ $LATITUDE ~= /-?[0-9]+\.[0-9]+/
# Captures the company name
^ $COMPANY_NAME != ''
# Uses the default country value
^ $COUNTRY == 'unknown'
---
Get User Posts
> requires: Get User
GET {{ BASE }}/posts
? userId = {{ USER_ID }}
& body.[0].id -> $FIRST_POST_ID
& body.[0].title -> $FIRST_POST_TITLE
&[Get User].body.email -> $USER_EMAIL
&[Get User].body.address.zipcode -> $USER_ZIPCODE
# Posts request succeeds
^ & status == 200
# Filters posts by the captured user id
^ & body.[0].userId == $USER_ID
# Captures the first post id
^ $FIRST_POST_ID != ''
# Captures the first post title
^ $FIRST_POST_TITLE != ''
# Reuses the captured user email
^ $USER_EMAIL ~= /@/
# Reuses the captured zipcode
^ $USER_ZIPCODE != ''