Command-line tool that generates multiple JSON objects from a JSON template and a wordlist. It allows modifying specific fields within json_data, either by replacing their values, adding the words as prefixes and/or suffixes, or generating sequential values.
curl -LsSf https://astral.sh/uv/install.sh | sh
echo 'eval "$(uv generate-shell-completion bash)"' >> ~/.bashrcuv syncuv run cambalache.py [OPTIONS] template.json wordlist.txt output.jsontemplate.json: Your base JSON file (the first object is used).wordlist.txt: File with one word per line (ignored in generator mode).output.json: Name of the resulting JSON file.
For the examples, we will use these input files:
template.json:
[
{
"testid": "tc101",
"description": "testcase",
"json_data": {
"email": "[email protected]",
"username": "testuser",
"city": "Lucinico"
}
}
]wordlist.txt:
user1
admin
test_ palabra
1. Replace ALL fields within json_data
(Default: if you don't specify --include or --ignore)
uv run cambalache.py template.json wordlist.txt output.jsonResult: 3 objects. In the first one, email, username, and city will be "user1". In the second, they will be "admin", etc.
2. Replace ONLY the email field
uv run cambalache.py template.json wordlist.txt output.json --include emailResult: 3 objects. email will be "user1", "admin", "test_ palabra". username and city remain original.
3. Replace ALL EXCEPT the city field
uv run cambalache.py template.json wordlist.txt soutput.json --ignore cityResult: 3 objects. email and username will be replaced by "user1", "admin", etc. city remains original ("Lucinico").
4. Generate by adding as a PREFIX to ALL fields
uv run cambalache.py template.json wordlist.txt output.json --prefixResult: 9 objects (3 words x 3 fields). You will have objects where email is "[dirección de correo electrónico eliminada]", others where username is "user1testuser", others where city is "user1Lucinico", and so on for "admin" and "test_ palabra".
5. Generate by adding as a SUFFIX to ALL fields
uv run cambalache.py template.json wordlist.txt output.json --suffixResult: 9 objects. You will have email as "[email protected]", username as "testuseruser1", city as "Lucinicouser1", etc.
6. Generate objects with PREFIX and SUFFIX (separate) for ALL fields
uv run cambalache.py template.json wordlist.txt output.json --bothResult: 18 objects (3 words x 3 fields x 2 [prefix and suffix]). For each word/field combination, it generates one object with a prefix and another with a suffix. E.g., one with email="[dirección de correo electrónico eliminada]" and another with email="[email protected]".
7. Generate with PREFIX, but ONLY for the username field
uv run cambalache.py template.json wordlist.txt output.json --prefix --include usernameResult: 3 objects. Only the username field is modified (e.g., "user1testuser"), the others remain as in the template.
8. Generate with SUFFIX, ignoring email and city (i.e., ONLY username)
uv run cambalache.py template.json wordlist.txt output.json --suffix --ignore email cityResult: 3 objects. Only username is modified with a suffix (e.g., "testuseruser1").
9. Generate with PREFIX and SUFFIX (separate), ONLY for email and city
uv run cambalache.py template.json wordlist.txt output.json --both --include email cityResult: 12 objects (3 words x 2 fields x 2 [prefix/suffix]). Objects modified only in email or city, with both prefix and suffix versions.
10. Generate sequential values for a specific field
uv run cambalache.py template.json dummy.txt output.json --gen usernameResult: 10 objects (by default). The username field will have sequential values like "testuser1", "testuser2", "testuser3", etc., based on the original value in the template. Other fields remain unchanged.
Example with a user template:
If your template has:
{
"json_data": {
"identificador": "usuario_example",
"email": "[email protected]",
"password": "abc123456"
}
}Running:
uv run cambalache.py usuarios.json dummy.txt usuarios_generados.json --gen identificadorWill generate objects with:
identificador: "usuario_example1", "usuario_example2", "usuario_example3", ...emailandpasswordremain as in the original template
Note: In generator mode (--gen), the wordlist file is required but ignored. You can use any dummy file as the second argument.
uv run cambalache.py --helpTEMPLATE_PATH: Path to the JSON template file (required)WORDLIST_PATH: Path to the wordlist file (required, but ignored in--genmode)OUTPUT_PATH: Path to the output JSON file (required)
--include -i: Specify which fields in json_data to modify exclusively--ignore -x: Specify which fields in json_data to ignore--prefix: Generation mode - add words as prefix to original values--suffix: Generation mode - add words as suffix to original values--both: Generation mode - create objects with both prefix AND suffix (separate objects)--gen: Generator mode - create sequential values for the specified field (e.g., user1, user2, user3...)
Note: The modes --prefix, --suffix, --both, and --gen are mutually exclusive.