DEV Community

Htet Ko
Htet Ko

Posted on โ€ข Edited on

2

๐Ÿš€ Introducing dynamic-json-generator: A Powerful Tool for Generating Fake JSON Data!

Hey Dev Community! ๐Ÿ‘‹

Iโ€™m excited to share my latest project with you all: dynamic-json-generator! ๐ŸŽ‰ This npm package is designed to help front-end developers quickly generate dynamic, fake JSON data for all your testing needs.

Why dynamic-json-generator?

When it comes to front-end development, having realistic test data is crucial. However, manually crafting this data can be tedious and time-consuming. Thatโ€™s where dynamic-json-generator comes in! ๐Ÿš€

๐ŸŒŸ What Is dynamic-json-generator?

dynamic-json-generator is an npm package that utilizes the power of @faker-js/faker to generate realistic JSON data for various testing scenarios. Whether you need single objects or a list of complex JSON structures, this tool has you covered.

๐Ÿ“ฆ Features

Single JSON Object Generation: Create a single JSON object based on a flexible template.
Multiple JSON Objects: Generate an array of JSON objects for bulk data testing.
Flexible Templates: Use a wide range of Faker data types including uuid, name, email, address, and more.

Supports Both CommonJS and ES Modules: Import with require or import based on your projectโ€™s needs.

๐Ÿ› ๏ธ Installation
To get started, simply run:

npm install dynamic-json-generator

Enter fullscreen mode Exit fullscreen mode

๐Ÿงฉ Usage
Hereโ€™s a quick example of how to use dynamic-json-generator:

const { generateJson, generateMultipleJson } = require('dynamic-json-generator');

// Define a template
const userTemplate = {
    id: 'uuid',
    name: 'fullName',
    address: {
        street: 'street',
        city: 'city',
    },
};

const postTemplate = {
    id: 'uuid',
    title: 'title',
    body: 'body',
    userId: 'uuid',
    image: 'imageUrl', // or 'image.url' like @faker-js/faker
};

// Generate a single JSON object (English locale)
const singleJsonEn = generateJson(userTemplate);
console.log(singleJsonEn);

// Generate multiple JSON objects (English locale)
const multipleJsonEn = generateMultipleJson(userTemplate, 20);
console.log(multipleJsonEn);

// Generate a single JSON object (Burmese locale)
const singleJsonMm = generateJson(userTemplate, 'mm');
console.log(singleJsonMm);

// Generate multiple JSON objects (Burmese locale)
const multipleJsonMm = generateMultipleJson(userTemplate, 20, 'mm');
console.log(multipleJsonMm);

Enter fullscreen mode Exit fullscreen mode

๐Ÿš€ Get Started Today!
Check out the GitHub repository for more details and contribute to the project. Feel free to open issues or submit pull requests for improvements.

Donโ€™t forget to โญ๏ธ the repository if you find it useful!

Demo App
Happy coding! ๐Ÿ’ป

Image of Timescale

๐Ÿš€ pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applicationsโ€”without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post โ†’

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up