Overview
The JsonParser block parses JSON strings into JavaScript objects so you can access their properties in assertions and subsequent blocks.Input Parameters
Required
Output Fields
On Success
On Failure
Examples
Basic Usage
- HttpRequest returns:
{ body: '{"id": 1, "name": "John"}' } - JsonParser parses to:
{ parsed: { id: 1, name: "John" } } - Stored in DataBus as:
user = { id: 1, name: "John" } - Assertions can access
user.idanduser.name
Using String Input Format
{ body: value }:
Access with: ${parsed.parsed.id}
Using Object Format (Recommended)
${user.id} (cleaner!)
Parsing Arrays
Error Handling
If parsing fails, the block returns an error:Common Patterns
HTTP Request + Parse
Nested Data Extraction
Multiple Parse Operations
Full Example
Tips
Always Use Object Output Format
Always Use Object Output Format
Map
parsed to a descriptive name for cleaner references:Handle Parse Errors Gracefully
Handle Parse Errors Gracefully
Check if parsing succeeded before making assertions:If
parsed doesn’t exist (parse failed), assertion will fail with clear message.Parse Before Validation
Parse Before Validation
Always parse JSON before using validation blocks:
When to Use
Use JsonParser when:- Parsing HTTP response bodies
- Converting JSON strings to objects
- Accessing nested JSON properties
- Response is already an object (not common in SemanticTest)
- Parsing streaming responses (use StreamParser)
Next Steps
HttpRequest
Make HTTP requests
ValidateContent
Validate parsed data

