Crates.io | rjo |
lib.rs | rjo |
version | 0.3.0 |
source | src |
created_at | 2019-04-06 13:30:46.904011 |
updated_at | 2021-01-23 08:45:21.198787 |
description | A small utility to create JSON objects. |
homepage | https://github.com/dskkato/rjo |
repository | https://github.com/dskkato/rjo |
max_upload_size | |
id | 126147 |
size | 33,703 |
A small utility to create JSON objects.
The origin of this package is jpmens/jo, and was inspired by a Golang ported version , skanehira/gjo.
Only installation from souce is supported. You may need Rust 1.30 or higher. You can then use cargo to build everything.
$ cargo install rjo
or, clone and specify local directory:
$ git clone https://github.com/dskkato/rjo.git
$ cd rjo
$ cargo install --path .
Creating objects:
$ rjo -p name=jo n=17 parser=false
{
"name": "jo",
"n": 17,
"parser": false
}
or, arrays:
$ seq 1 10 | rjo -a
[1,2,3,4,5,6,7,8,9,10]
$ rjo -p -a Rust 0 false
[
"Rust",
0,
false
]
A more complex example:
$ rjo -p name=JP object=$(rjo fruit=Orange point=$(rjo x=10 y=20) number=17) sunday=false
{
"name": "JP",
"object": {
"fruit": "Orange",
"point": {
"x": 10,
"y": 20
},
"number": 17
},
"sunday": false
}
stdin
Currently, jo
assumes one x=y pair per line when reads from stdin, and multiple x=y pairs generate following results:
echo -e "a=b c=d \n e=f g=h" | jo
{"a":"b c=d "," e":"f g=h"}
While, rjo
translates stdin
input line by line:
echo -e "a=b c=d \n e=f g=h" | rjo
{"a":"b","c":"d"}
{"e":"f","g":"h"}
MIT