| Crates.io | rjg |
| lib.rs | rjg |
| version | 0.4.1 |
| created_at | 2024-09-13 02:05:15.748712+00 |
| updated_at | 2026-01-10 07:44:09.023014+00 |
| description | Random JSON Generator |
| homepage | https://github.com/sile/rjg |
| repository | https://github.com/sile/rjg |
| max_upload_size | |
| id | 1373277 |
| size | 21,604 |
Random JSON Generator.
rjg reads a JSON template from stdin and generates random JSON values based on embedded generator patterns.
// Install
$ cargo install rjg
// Generate integer arrays
$ echo '[0, "$u4", 9]' | rjg --count 3
[0,8,9]
[0,6,9]
[0,5,9]
// Generate objects
$ echo '{"put": {"key": "$s[3]", "value": {"$oneof": [null, "$u16"]}}}' | rjg --count 3
{"put":{"key":"cic","value":63308}}
{"put":{"key":"b36","value":10142}}
{"put":{"key":"9dj","value":null}}
// Print help.
$ rjg -h
Random JSON Generator
Usage: rjg [OPTIONS]
Options:
-h, --help Print help ('--help' for full help, '-h' for summary)
--version Print version
-c, --count <INTEGER> Number of JSON values to generate [default: 1]
-s, --seed <INTEGER> Seed for the random number generator
$ (e.g., "$u8", "$i32", "$s[5]", "$seqno")$oneof key"$seqno": Generates a sequence number starting from 0 and incrementing by 1 for each occurrence of $seqno during generation (even within a single JSON value)"$u<bits>": Generates a random unsigned integer with the specified bit width (e.g., "$u8", "$u16"; 1-64 bits)"$i<bits>": Generates a random signed integer with the specified bit width (e.g., "$i8", "$i32"; 1-64 bits)"$s[<length>]": Generates a random alphanumeric string of the specified length (e.g., "$s[5]"; minimum 1 character){"$oneof": [VALUE, ...]}: Randomly selects and outputs one value from the provided array