Automate Your JSON Mock Data with DTM Data Generator

How to Use DTM Data Generator for JSON — A Step-by-Step Guide

Generating realistic, structured JSON test data helps speed development, testing, and demo workflows. This guide walks you through using the DTM Data Generator to create JSON datasets quickly and reliably, from installation to advanced templating.

What you’ll get

  • A working installation of DTM Data Generator
  • A JSON template and sample generated output
  • Tips for repeating patterns, nested objects, arrays, and custom value rules

Step 1 — Install DTM Data Generator

  1. Download the appropriate package or binary for your OS from the official distribution (pick the version matching your platform).
  2. Install:
    • macOS / Linux: extract and place the binary in a directory on your PATH (e.g., /usr/local/bin).
    • Windows: unzip and add the folder to your PATH or use the provided installer.
  3. Verify installation by running:

    Code

    dtm –version

    You should see the tool version printed.

Step 2 — Create a JSON template

DTM uses templates to define structure and generation rules. Create a file named sample-template.json.dt (or similar). Example template producing user records:

Code

{ “users|{{count:50}}”: [

{   "id|{{uuid}}": "{{uuid}}",   "firstName|{{firstName}}": "{{firstName}}",   "lastName|{{lastName}}": "{{lastName}}",   "email|{{email}}": "{{email}}",   "age|{{int:min=18,max=80}}": {{int:min=18,max=80}},   "isActive|{{bool:prob=0.8}}": {{bool:prob=0.8}},   "signupDate|{{date:from='2022-01-01',to='2025-12-31',format='iso'}}": "{{date:from='2022-01-01',to='2025-12-31',format='iso'}}",   "address": {     "street|{{streetAddress}}": "{{streetAddress}}",     "city|{{city}}": "{{city}}",     "postalCode|{{postalCode}}": "{{postalCode}}",     "country|{{country}}": "{{country}}"   },   "preferences": {     "newsletter|{{bool:prob=0.3}}": {{bool:prob=0.3}},     "tags|{{array:min=0,max=5}}": [       "{{word}}"     ]   } } 

] }

Notes:

  • Left-hand keys show DTM directives; right-hand values are example placeholders.
  • Use built-in generators like uuid, firstName, city, int, bool, date, array, etc.
  • Adjust counts, ranges, and probabilities to match your needs.

Step 3 — Run the generator

From the directory containing your template: “` dtm generate -i sample-template.json.dt -o sample-data.json

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *