Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dskkato/rjo
A small utility to create JSON objects, written in Rust.
https://github.com/dskkato/rjo
command-line json rust
Last synced: 2 months ago
JSON representation
A small utility to create JSON objects, written in Rust.
- Host: GitHub
- URL: https://github.com/dskkato/rjo
- Owner: dskkato
- License: mit
- Created: 2019-02-26T11:45:31.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-06T02:15:22.000Z (over 1 year ago)
- Last Synced: 2024-10-13T23:17:54.102Z (3 months ago)
- Topics: command-line, json, rust
- Language: Rust
- Homepage:
- Size: 224 KB
- Stars: 64
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-for-oneliner - rjo - A small utility to create JSON objects from command-line arguments written in Rust (JSON / Open USP Tsukubai)
README
# rjo
[![rjo](https://img.shields.io/crates/v/rjo.svg)](https://crates.io/crates/rjo)
[![Build Status](https://travis-ci.org/dskkato/rjo.svg?branch=master)](https://travis-ci.org/dskkato/rjo)
[![Build status](https://ci.appveyor.com/api/projects/status/9cu385votebtm92e/branch/master?svg=true)](https://ci.appveyor.com/project/dskkato/rjo)
[![codecov](https://codecov.io/gh/dskkato/rjo/branch/master/graph/badge.svg)](https://codecov.io/gh/dskkato/rjo)A small utility to create JSON objects.
![](img/ss.png)
The origin of this package is [jpmens/jo](https://github.com/jpmens/jo), and was inspired by a Golang ported version , [skanehira/gjo](https://github.com/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.
```sh
$ cargo install rjo
```or, clone and specify local directory:
```sh
$ 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:
```sh
$ 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:
```sh
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
* [jo](https://github.com/jpmens/jo)
* [gjo](https://github.com/skanehira/gjo)## License
MIT