Skip to main content

Overview

The JsonParser block parses JSON strings into JavaScript objects so you can access their properties in assertions and subsequent blocks.

Input Parameters

Required

ParameterTypeDescription
bodystringJSON string to parse

Output Fields

On Success

FieldTypeDescription
parsedobject/arrayThe parsed JSON data

On Failure

FieldTypeDescription
errorstringError message describing parse failure
rawstringOriginal unparsed body

Examples

Basic Usage

Flow:
  1. HttpRequest returns: { body: '{"id": 1, "name": "John"}' }
  2. JsonParser parses to: { parsed: { id: 1, name: "John" } }
  3. Stored in DataBus as: user = { id: 1, name: "John" }
  4. Assertions can access user.id and user.name

Using String Input Format

This automatically wraps the string as { body: value }: Access with: ${parsed.parsed.id}
Access with: ${user.id} (cleaner!)

Parsing Arrays

Error Handling

If parsing fails, the block returns an error:
You can check for errors in assertions:
Or assert success by checking the parsed data exists:

Common Patterns

HTTP Request + Parse

Nested Data Extraction

Multiple Parse Operations

Full Example

Tips

Map parsed to a descriptive name for cleaner references:
Check if parsing succeeded before making assertions:
If parsed doesn’t exist (parse failed), assertion will fail with clear message.
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
Don’t use when:
  • Response is already an object (not common in SemanticTest)
  • Parsing streaming responses (use StreamParser)

Next Steps

HttpRequest

Make HTTP requests

ValidateContent

Validate parsed data