{"id":19124763,"url":"https://github.com/mitinarseny/jg","last_synced_at":"2026-04-18T03:32:37.561Z","repository":{"id":96162997,"uuid":"237080703","full_name":"mitinarseny/jg","owner":"mitinarseny","description":"JSON generator","archived":false,"fork":false,"pushed_at":"2021-03-09T13:39:07.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T13:58:52.837Z","etag":null,"topics":["generator","json"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitinarseny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-29T20:56:34.000Z","updated_at":"2021-08-24T07:12:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc1a99f6-9683-4a23-9cb2-d666588678b9","html_url":"https://github.com/mitinarseny/jg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mitinarseny/jg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fjg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fjg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fjg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fjg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitinarseny","download_url":"https://codeload.github.com/mitinarseny/jg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitinarseny%2Fjg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31955712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","json"],"created_at":"2024-11-09T05:30:27.907Z","updated_at":"2026-04-18T03:32:37.542Z","avatar_url":"https://github.com/mitinarseny.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jg\n`jg` is a [JSON](https://www.json.org/json-en.html) generator written in [Go](https://golang.org).  \nIt can generate JSON documents of any complexity from human-friendly [YAML schema](#schema).\n\n## Why another JSON generator?\nThere are some other JSON generators:\n* [GeneratedData](https://www.generatedata.com)\n* [JSON Generator](https://www.json-generator.com)\n\nUnfortunately, these generators are not flexible enough in strings generation.\nThey support only a fixed range of categories (e.g. *Name*, *City*, *Country*, etc...)\nwhich are *internally* selected appropriate wordlist to take strings from.\nSo there is no way to manually pass a dictionary to these generators.\n\n`jg` supports passing external dictionaries with [files](#files) flag.\n\n## Usage\n```bash\nλ jg --help\nUsage: jg [OPTIONS] SCHEMA\n\nJSON generator\n\nOptions:\n  -a, --array [min,]max         Generate array of root objects (0 means do not wrap in array)\n  -f, --files stringToString    Bind files to their names in schema (default [])\n  -n, --nosort                  Do not sort keys in objects\n  -o, --output string           JSON output (default \"/dev/stdout\")\n      --output-buff-size uint   Buffer size for JSON output (0 means no buffer) (default 1024)\n  -s, --stream int              Stream root objects delimited by newline (-1 means endless)\n```\n\n## Install\nAt the moment, only installing by compiling source code is available.\nSo you should have [Go](https://golang.org) installed.\n```bash\n# clone it outside GOPATH\ngo get github.com/mitinarseny/jg\n\n# get dependencies using go modules (needs go 1.11+)\ngo get ./...\n\n# build\ngo build -o jg ./cmd\n\n# check it works\n./jg --help\n```\n\n## Schema\nSchema is defined in [YAML](https://yaml.org) format. Here is a small example:\n```yaml\nfiles:\n  file1:\n\nroot:\n  type: object\n  fields:\n    field1: int\n    field2:\n      type: string\n      from: file1\n```\n\n\u003e See [examples](/examples) for more.\n\nThere are two top-level fields:\n* `root: node`\n* `files: object`: mapping with file names.  \n  These names are **not** real paths in file system. They can be mapped to real files with [files](#files) CLI argument.  \n  Each file must contain strings separated with newline character `\\n`.\n  ```yaml\n  files:\n    file1:\n    file2:\n    # ...\n    fileN:\n  ```\n\nEach node (even `root`) must specify its type with [`type`](#types) field:\n\n```yaml\nroot:\n  type: object\n  fields:\n    field1:\n      type: int\n```\n\n## Types\n\nHere is the list of supported node types:\n\n* [`bool`](#bool)\n* [`int`](#int)\n* [`float`](#float)\n* [`string`](#string)\n* [`object`](#object)\n* [`array`](#array)\n\nTypes [`bool`](#bool), [`int`](#int) and [`float`](#float) can be inlined.\nIn this case, the defaults are applied for each type correspondingly.\n```yaml\nboolInline: bool\nboolExplicit:\n  type: bool\n\nintegerInline: int\nintegerExplicit:\n  type: int\n  range: [0, 100]\n\nfloatInline: float\nfloatExplicit:\n  type: float\n  range: [0, 1]\n```\n\n### `bool`\nA boolean value. It simply generates `true` or `false` in output JSON.\n\n### `int`\nAn integer number. It can have only one of possible fields:\n* `range: {int | [int, int]}` (default `[0, 10]`)  \n  Range of posssible values (with maximum **included**). It can be one of the following types:\n  * `int`: equivalent to `[0, int]`\n    ```yaml\n    range: 10 # [0, 10]\n    ```\n  * `[int, int]`: minimum and maximum correspondingly\n    ```yaml\n    range: [0, 10]\n    ```\n* `choices: []int`\n  Possible choices. Example:\n  ```yaml\n  choices: [2, 3, 5, 7, 11, 13, 17, 19]\n  ```\n\n### `float`\nAn floating-point number. It can have only one of possible fields:\n* `range: {int | [float, float]}` (default `[0, 1]`)  \n  Interval of posssible values (with maximum **excluded**). It can be one of following types:\n  * `float`: equivalent to `[0, float]`\n    ```yaml\n    range: 7.7\n    ```\n  * `[float, float]`: minimum and maximum correspondingly\n    ```yaml\n    range: [5.2, 11.3]\n    ```\n* `choices: []float`\n  Possible choices. Example:\n  ```yaml\n  choices: [3.14, 2.71, 4.20]\n  ```\n\n### `string`\nA string value. It must specify one of the following fields:\n* `from: string`: name of file to take strings from. This name should be listed in [files](#files) top-level field.\n  ```yaml\n  files:\n    someFile:\n  \n  root:\n    stringFromFile:\n      type: string\n      from: someFile\n  ```\n* `choices: []string`\n  Possible choices. Example:\n  ```yaml\n  choices:\n    - choice 1\n    - choice 2\n    - choice 3\n  ```\n\n\n### `array`\nAn array object. It must specify its `elements`.\n* `elements: node`\n  Defines an element of array. It can be node of any [type](#types).\n* `length: {uint | [uint, uint]}` (default: `10`)\n  Length of array to generate. It can be one of the following types:\n  * `uint`: exact length of array\n    ```yaml\n    length: 10\n    ```\n  * `[uint, uint]`: minimum and maximum of length correspondingly\n    ```yaml\n    length: [0, 10]\n    ```\n\n### `object`\nAn object. It must specify its `fields`:\n* `fields: object`: mapping of field names to nodes. Example:\n  ```yaml\n  type: object\n  fields:\n    a: int\n    b: float\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Fjg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitinarseny%2Fjg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitinarseny%2Fjg/lists"}