Skip to content

nephh/ez-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ez-json logo

GitHub License

EZ JSON is a CLI tool that generates JSON data based on user input. The goal is to eliminate the tedious task of manually writing out JSON data and seed files, to quickly create mock data for testing or development purposes. Whether you need to quickly test an endpoint, or you need a huge seed file, EZ JSON makes it easy, and most importantly, fast.

Table of Contents

Installation

To install the tool, you'll need to have Node.js installed on your computer. Once you have Node.js installed, you can install the tool by cloning the repository and installing its dependencies:

mkdir ez-json
git clone https://github.com/nephh/ez-json
cd ez-json
npm install

For now, EZ JSON must be cloned and ran like any normal JavaScript file. Very soon™️ it will be an NPM package that can be globally installed, so you can generate your data from anywhere.

Usage

EZ-JSON allows you to generate JSON objects based on key-value pairs that you define. This tool takes care of the JSON formatting for you, so you can focus on the data you want to generate.

To use EZ-JSON, run the following command:

node init.js [options] <objects>

In this command, <objects> represents the number of JSON objects you want to generate. If you don't specify a number, EZ-JSON will generate a single object by default.

The available options are:

  • -s, --save: Save the generated JSON to a file named "ez-json.json".

  • -h, --help: The help menu.

  • -v, --version: See what version of EZ-JSON you are running.

Examples

Here are a few examples of how to use EZ-JSON:

  • To generate a single JSON object and print it to the console, run:

    node init.js
  • To generate 5 JSON objects, print them to the console, and save them to a file, run:

    node init.js -s 5

Remember, you can combine options to tailor the command to your needs.

ez-json example

Future Features

This project is very much in it's infancy, so there are quite a few features, bugs, and edge cases that are being worked on, and more are always being thought of. Click here if you want to see the madness of my mind.

As of right now, the string generation is very barebones and random. Very soon™️ more specific keys will be checked, so that more accurate values will be generated from a set dictionary based on the keys. The specificity of the values generated is not very deep at the moment.

Deal with duplicate numbers, as of now if you need to generate 100 users all with unique userIds, there's gonna be duplicates. Adding a flag to not allow duplicate numbers is high priority, while more advanced cases will probably need to be handled in a more customizable way.

I also want to make this extendable, which means allowing users to specify a custom regex or a predefined set of words for more explicit values. User defined dictionaries used for specific keys, existing JSON file importing, all these things are future ideas focused on allowing the user to customize their JSON generation to their hearts content.

Whether these customizations will become extra arguments in the CLI, or a config file is still up for debate. A config would probably be best for more in-depth custom values.

I plan on rewriting this in Go, but I first need to learn the ins and outs of the language, so this will live on node for now.

Once this is an official npm package, installing with the --global flag will allow you to generate JSON in any directory.

Project Structure

  • init.js: The main script that runs the JSON generator.

  • utils/: Contains utility modules for the project.

    • input.js: Handles input from the command line.

    • jsonGenerator.js: Contains functions for generating JSON data.

    • randomGenerator.js: Contains functions for generating random data.

    • yargs.js: Handles command line arguments using yargs.

Thank You

There are many JSON file generators out there that have very in-depth generation, but they don't capture the simplicity and speed that I hope to bring with EZ JSON.

Thank you for checking it out, and for being here along for the ride ^-^

Feel free to contact me here on GitHub, I love to chat about anything programming or art related!

Contributing

Contributions are welcome. Please submit a pull request or create an issue to propose changes or additions.

License

This project is licensed under the Apache 2.0 license.

About

Automate the tediousness of writing JSON. No more trailing commas :)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published