Crates.io | cout2json |
lib.rs | cout2json |
version | 0.1.1 |
source | src |
created_at | 2024-04-30 18:48:32.212494 |
updated_at | 2024-10-10 10:08:01.339911 |
description | Converts cout output to json |
homepage | |
repository | https://github.com/m-dupont/cout2json |
max_upload_size | |
id | 1225413 |
size | 47,505 |
Cout2json is a utility that generates JSON structures from cout output. In a program, you construct the JSON object by printing key values in the terminal.
Example:
printf ";key:value" | cout2json # give {"key":"value"}
printf ";key1:value1\n;key2:value2" | cout2json # give {"key1":"value1","key2":"value2"}
printf ";a.b.c:value" | cout2json # give {"a":{"b":{"c":"value"}}}
The output can be piped to tools like jq to further process the output.
printf ";key1.b:1\n;key2.d:2" | cout2json | jq ".key2" -c # give {"d":2}
cargo install cout2json
printf ";key1.key2:1" | cout2json # give {"key1":{"key2":1}}
printf ";key1.key2.key3:1" | cout2json # give {"key1":{"key2":{"key3":1}}}
printf ";key1.key2:1\n;key1.key3:2" | cout2json # give {"key1":{"key2":1,"key3":2}}
printf ";key:1" | cout2json # give {"key":1}
printf ";key:1.0" | cout2json # give {"key":1.0}
printf ";key:a" | cout2json # give {"key":"a"}
printf ";key:1\n;key:2" | cout2json # give {"key":[1,2]}
printf ";key.a:1\n;key.b:2" | cout2json # give {"key":{"a":1,"b":2}}