Skip to main content

Scenario

This guide uses the classic Pet Store example to build a fully enriched output JSON by combining the following sources:
  • Request body fields (JSONPath)
  • Two request headers (Content-Type, X-Request-Id)
  • A query parameter (format)
  • Context variables (HTTP method, client IP, correlation ID, year, date-time, environment)
  • JEXL ternary expressions (conditional operation type, computed summary)
  • Custom intermediate variables (petName, categoryLabel, statusLabel, nestedObject)

Input Request


Step 1: Extract Intermediate Custom Variables

Row 1 — Pet Name

Row 2 — Category Label

Row 3 — Status Label


Step 2: Conditional Nested Object

Row 4 — Default (null)

Row 5 — Available Status Override

The template above contains { and } characters, which are nested curly braces inside the #{} expression block. The balanced brace scanner in the Message Builder correctly handles this without breaking the parsing.

Step 3: Final Body Template

Row 6 — Build Enriched JSON


Expected Output


Key Points

Define intermediate custom variables first, then use them in the final template. This approach keeps the template clean and maintainable.