{"id":15111304,"url":"https://github.com/sile/rjg","last_synced_at":"2025-10-23T04:31:18.620Z","repository":{"id":256871423,"uuid":"856301178","full_name":"sile/rjg","owner":"sile","description":"Random JSON Generator","archived":false,"fork":false,"pushed_at":"2025-04-10T14:10:00.000Z","size":58,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T21:27:52.768Z","etag":null,"topics":["command-line-tool","json","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-09-12T10:49:11.000Z","updated_at":"2025-04-10T14:09:42.000Z","dependencies_parsed_at":"2025-02-08T08:31:05.407Z","dependency_job_id":null,"html_url":"https://github.com/sile/rjg","commit_stats":null,"previous_names":["sile/rjg"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sile/rjg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frjg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frjg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frjg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frjg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/rjg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frjg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280562666,"owners_count":26351727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"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":["command-line-tool","json","rust"],"created_at":"2024-09-26T00:03:11.773Z","updated_at":"2025-10-23T04:31:18.615Z","avatar_url":"https://github.com/sile.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"rjg\n===\n\n[![rjg](https://img.shields.io/crates/v/rjg.svg)](https://crates.io/crates/rjg)\n[![Actions Status](https://github.com/sile/rjg/workflows/CI/badge.svg)](https://github.com/sile/rjg/actions)\n![License](https://img.shields.io/crates/l/rjg)\n\nRandom JSON Generator.\n\n```console\n// Install.\n$ cargo install rjg\n\n// Generate integer arrays.\n$ rjg --count 3 '[0, {\"$int\": {\"min\": 1, \"max\": 8}}, 9]'\n[0,3,9]\n[0,8,9]\n[0,5,9]\n\n// Generate objects with user-defined variables.\n$ rjg --count 3 \\\n      --var key='{\"$str\": [\"key_\", \"$alpha\", \"$alpha\", \"$digit\"]}' \\\n      --var val='{\"$option\": \"$u16\"}' \\\n      '{\"put\": {\"key\": \"$key\", \"value\": \"$val\"}}'\n{\"put\":{\"key\":\"key_im3\",\"value\":56386}}\n{\"put\":{\"key\":\"key_qd0\",\"value\":null}}\n{\"put\":{\"key\":\"key_ag4\",\"value\":49477}}\n\n// Print help.\n$ rjg -h\nRandom JSON Generator\n\nUsage: rjg [OPTIONS] \u003cJSON_TEMPLATE\u003e\n\nExample:\n  $ rjg '[0, {\"$int\": {\"min\": 1, \"max\": 8}}, 9]'\n\nArguments:\n  \u003cJSON_TEMPLATE\u003e JSON template used to generate values\n\nOptions:\n  -h, --help                     Print help ('--help' for full help, '-h' for summary)\n      --version                  Print version\n  -c, --count \u003cINTEGER\u003e          Number of JSON values to generate [default: 1]\n  -p, --prefix \u003cSTRING\u003e          Prefix for variable and generator names [default: $]\n  -s, --seed \u003cINTEGER\u003e           Seed for the random number generator\n  -v, --var \u003cNAME=JSON_TEMPLATE\u003e User-defined variables\n```\n\nRules\n-----\n\n- Literal JSON values within a JSON template are outputted exactly as they are\n- Non-literal JSON values are classified as follows:\n  - **Variables**: JSON strings starting with the `$` prefix\n  - **Generators**: Single-member objects with a key starting with the `$` prefix\n  - NOTE:\n    - The prefix can be changed using `--prefix` option.\n    - Both variables and generators cannot be used as object names.\n- **Variables**:\n  - Variables can be [pre-defined](#pre-defined-variables) or user-defined (the latter are defined via `--var` option)\n  - The value of a variable is evaluated to a JSON value when generating a JSON value\n- **Generators**:\n  - [Generators](#generators) produce a random JSON value based on their content\n\nGenerators\n----------\n\n### `int`\n\n`int` generator produces a JSON integer between `min` and `max`.\n\n```\n{\"$int\": {\"min\": INTEGER, \"max\": INTEGER}}\n```\n\n#### `int` examples\n\n```console\n$ rjg --count 3 '{\"$int\": {\"min\": -5, \"max\": 5}}'\n-3\n5\n4\n```\n\n### `str`\n\n`str` generator procudes a JSON string by concating the values with in the given array.\nNote that `null` values are filtered out from the result.\n\n```\n{\"$str\": [VALUE, ...]}\n```\n\n#### `str` examples\n\n```console\n$ rjg --count 3 '{\"$str\": [\"$digit\", \" + \", \"$digit\"]}'\n\"1 + 0\"\n\"7 + 5\"\n\"0 + 8\"\n\n$ rjg --count 3 '{\"$str\": [{\"$option\": \"_\"}, \"$alpha\", \"$alpha\", \"$digit\"]}'\n\"Ae8\"\n\"_UQ6\"\n\"Cd1\"\n\n$ rjg --count 3 '{\"$str\": {\"$arr\": {\"len\": 8, \"val\": \"$digit\"}}}'\n\"84534098\"\n\"91367444\"\n\"16584252\"\n```\n\n### `arr`\n\n`arr` generator produces a JSON array based on the provided length and value.\nUnlike other generators, `arr` postpones the evaluation of `val` until each individual array item is generated.\n\n```\n{\"$arr\": {\"len\": INTEGER, \"val\": VALUE}}\n```\n\n#### `arr` examples\n\n```console\n$ rjg --count 3 '{\"$arr\": {\"len\": 3, \"val\": \"$digit\"}}'\n[0,0,2]\n[6,7,3]\n[1,7,5]\n\n$ rjg --count 3 '{\"$arr\": {\"len\": \"$digit\", \"val\": \"$digit\"}}'\n[7,4,5,0,4]\n[6,2,4,2,6,9,3]\n[]\n```\n\n### `obj`\n\n`obj` generator produces a JSON object from an array of objects that specify a name and value.\nNote that `null` values in the array are ignored when producing the resulting object.\n\n```\n{\"$obj\": [{\"name\": STRING, \"val\": VALUE} | null, ...]}\n```\n\n#### `obj` examples\n\n```console\n$ rjg --count 3 '{\"$obj\": [{\"name\":\"foo\", \"val\":\"$u8\"}, {\"$option\":{\"name\":\"bar\", \"val\":\"$i8\"}}]}'\n{\"foo\":119}\n{\"bar\":-75,\"foo\":42}\n{\"bar\":-87,\"foo\":233}\n\n$ rjg --count 3 --var key='{\"$str\": [\"$alpha\", \"$alpha\"]}' '{\"$obj\": [{\"name\":\"$key\", \"val\":\"$u8\"}]}'\n{\"jz\":63}\n{\"MA\":234}\n{\"Ir\":164}\n```\n\n### `oneof`\n\n`oneof` generator selects a JSON value from the given array.\n\n```\n{\"$oneof\": [VALUE, ...]}\n```\n\n#### `oneof` examples\n\n```console\n$ rjg --count 3 '{\"$oneof\": [\"foo\", \"bar\", \"baz\"]}'\n\"bar\"\n\"bar\"\n\"foo\"\n```\n\n### `option`\n\n`option` is syntactic sugar for `oneof`.\nThat is, `{\"$option\": VALUE}` is equivalent with `{\"$oneof\": [VALUE, null]}`.\n\nPre-defined variables\n---------------------\n\n### `i`\n\n`i` represents the current iteration count.\n\n```console\n$ rjg --count 3 '\"$i\"'\n0\n1\n2\n```\n\n### `u8`, `u16`, `u32`, `i8`, `i16`, `i32`, `i64`, `digit`\n\nInteger variables.\nEach integer variable represents a JSON integer within the pre-defined range.\n\n```console\n$ rjg --count 3 '\"$u8\"'\n67\n21\n75\n\n$ rjg --count 3 '\"$i32\"'\n-713325780\n-1502802973\n172465743\n```\n\n### `bool`\n\n`bool` represents `true` or `false`.\n\n```console\n$ rjg --count 3 '\"$bool\"'\nfalse\ntrue\nfalse\n```\n\n### `alpha`\n\n`alpha` represents a JSON string containing an alphabetic character from the ASCII character set.\n\n```console\n$ rjg --count 3 '\"$alpha\"'\n\"h\"\n\"A\"\n\"g\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Frjg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Frjg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Frjg/lists"}