Coder Social home page Coder Social logo

jsogen's Introduction

JavaScript Object GENerator

JSOGEN is a random JSON generator. The instances are generated from the supplied template. The template is a JSON file that can contain special expressions for each string wrapped in {{ and }}.

The script can be executed as

$ python jsogen/jsogen.py [-h] [-s SEED] [-o OUTPUT] [-q] template

where the meaning of arguments is following:

template                     template file or directory
-h, --help                   show this help message and exit
-s SEED, --seed SEED         random generator seed value
-o OUTPUT, --output OUTPUT   output file or directory (if not specified std out is used)
-q, --quiet                  do not print any debug info

The most important parameter is template that contains path to the template file. If the path is a directory, all template files in the directory are recursively generated to the OUTPUT directory that is required in this case.

Template file

Let's start with example:

[
    "{{repeat(1, 2)}}",
    {
        "boolean": "{{boolean()}}",
        "int": "{{integer(-100, 999)}}",
        "str": "{{string(10, 20)}}",
        "float": "{{float(-10, 10, precision=4)}}"
    }
]

Executing jsogen on this template will generate array with 1 or 2 object elements. Each object will contain 4 fields with keys equal to the values in the example. The boolean element will be boolean element that is either true or false, the int will be integer in the range [-100, 999], the str with 10 to 20 characters and the last one float value in the range [-10, 10] with precision 4. An example result could be following:

[
    {
        "int": 150,
        "str": "dasflkg asdfk ds",
        "boolean": true,
        "float": 2.4356
    }
]

Note that the order of columns in object does not have to be the same.

jsogen's People

Contributors

bukka avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.