#json

app rjo

A small utility to create JSON objects

9 releases

0.3.0 Jan 23, 2021
0.2.3 Dec 29, 2019
0.2.2 Jun 16, 2019
0.2.1 Apr 15, 2019
0.1.6 Apr 6, 2019

#1834 in Command line utilities

Download history 10/week @ 2022-11-20 1/week @ 2022-11-27 2/week @ 2022-12-04 1/week @ 2022-12-11 10/week @ 2022-12-18 2/week @ 2022-12-25 10/week @ 2023-01-08 1/week @ 2023-01-15 3/week @ 2023-01-22 7/week @ 2023-01-29 17/week @ 2023-02-05 36/week @ 2023-02-12 18/week @ 2023-02-19 2/week @ 2023-03-05

57 downloads per month

MIT license

15KB
299 lines

rjo

rjo Build Status Build status codecov

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.

Installation

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 .

Usage

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
}

multiple lines from 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"}

See also

License

MIT

Dependencies

~6.5MB
~122K SLoC