Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Varbase FAQs 9.2.1 Minor update available for module varbase_faqs (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows you to create JSON templates with placeholders that can be dynamically filled with data. This is useful for building API payloads from form submissions or transforming data for other services. You can manage these templates and their data mappings through an administrative interface.

The JSON Resolver module provides a flexible service for resolving JSON
templates with dynamic token replacement. It enables developers to define JSON
payload templates with placeholders that are replaced with actual data from
submission arrays at runtime. This module is JSON structure agnostic.

Use case

You have webforms to capture data and dynamically prepare the payload with a predefined structure.

This is particularly useful for

  • Building API payloads from webform submissions
  • Transforming data structures for third-party integrations
  • Creating dynamic JSON responses with configurable templates
  • Mapping form data to external service requirements

Key Features

  • Token-based template system with nested data support
  • Multiple configurable template types
  • Clean service-based architecture with dependency injection
  • Admin UI for template management via Configuration → System → JSON Resolver
  • Comprehensive logging and error handling

Requirements

This module requires no modules outside of Drupal core.

Installation

Install as you would normally install a contributed Drupal module. For further
information, see:
https://www.drupal.org/docs/extending-drupal/installing-modules.

Configuration

Navigate to Administration → Configuration → System → JSON Resolver Settings (admin/config/system/json-resolver)
Grant the "Administer JSON Resolver" permission to the appropriate roles at Administration → People → Permissions
Configure the token map and templates:

Token Map Configuration

Define token-to-field mappings in JSON format. This maps the tokens used in
templates to actual field names in your submission data.

Example token map

{
  "amount": "donation_amount",
  "email": "donor_email",
  "firstName": "donor.first_name",
  "card": "payment.credit_card.number"
}

How it works

  • Keys are token names used in templates as {{tokenName}}
  • Values are paths to data in submission arrays
  • Supports dot notation for nested data access

Template Management

Add, edit, or delete JSON payload templates:
To add a template

  • Enter a unique machine name (lowercase letters and underscores only)
  • Provide the JSON template with token placeholders (e.g., {{amount}})
  • Click "Add template"

To edit a template

  • Modify the JSON in the "Existing templates" section
  • Click "Save configuration"

To delete a template

  • Click the "Delete" button next to the template
  • Confirm deletion

Example unresolved JSON template

{
  "transaction": {
    "amount": "{{amount}}",
    "currency": "{{currency}}"
  },
  "donor": {
    "email": "{{email}}",
    "name": "{{firstName}} {{lastName}}"
  }
}

Usage Example

Architecture Overview
The module provides a service-based architecture following Drupal best practices.

Service ID: json_resolver.resolver
Interface: Drupal\json_resolver\Services\JsonResolverInterface
Implementation: Drupal\json_resolver\Services\JsonResolverService

Basic Token Resolution Example

use Drupal\json_resolver\Services\JsonResolverInterface;

class MyService {

  protected $jsonResolver;

  public function __construct(JsonResolverInterface $json_resolver) {
    $this->jsonResolver = $json_resolver;
  }

  public function processData(array $submission_data) {
    $template_name = "SAMPLE"; // Define your template name stored in the module config.

    // Your submission data. This could be dynamic from your webform.
    // This should match the token field map.
    $submission_data = [
      'amount' => '100.00',
      'email' => '[email protected]',
    ];

    // Resolve template with actual data
    $result = $this->jsonResolver->resolve($template_name, $submission_data);

    // Result: ['amount' => '100.00', 'email' => '[email protected]']
    return $result;
  }
}

Activity

Total releases
2
First release
Feb 2026
Latest release
4 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.0.0-beta2 Pre-release Feb 20, 2026
1.0.0-beta1 Pre-release Feb 16, 2026