Skip to content

chaosteil/serde_shon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serde_shon

Crates.io GitHub Workflow Status

serde_shon is a Rust library for parsing the SHON data format. The definition of the format is based on the description present in shon-go.

This library is intended to be used with Serde.

SHON?

SHON (pronounced 'shawn') is short for Shell Object Notation. It is a notation for expressing complex objects at the command line. Because it is intended to be used on the command line, it aims to reduce extraneous commas and brackets.

All JSON objects can be expressed via SHON, typically in a format that is easier to specify on the command line.

JSON SHON
{"hello": "World"} [ --hello World ]
["beep", "boop"] [ beep boop ]
[1, 2, 3] [ 1 2 3 ]
[] [ ] or []
{"a": 10, b: 20} [ --a 10 --b 20 ]
{} [--]
1 1
-1 -1
1e3 1e3
"hello" hello
"hello world" 'hello world'
"10" -- 10
"-10" -- -10
"-" -- -
"--" -- --
true -t
false -f
null -n

Installation

Include the library as part of the dependencies in Cargo.toml:

[dependencies]
serde_shon = "0.1.0"

Usage

use serde::Deserialize;
use serde_shon::from_args;
use std::env;

#[derive(Deserialize, Debug)]
struct Data {
    field: Option<String>,
}

fn main() {
    let d: Data = from_args(env::args()).unwrap();
    dbg!(d.field);
}

And you will be able to call your application as such:

$ ./binary [ --field hello ]
d.field = Some(
    "hello",
)

Features

The serializer supports common Rust data types for serialization and deserialization, like enums and structs.

The library might currently still have a few bugs and be incomplete in the implementation. If you find something troubling, either write up an issue or perhaps even a PR, contributions are always welcome.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages