Giter Site home page Giter Site logo

serde_shon's Introduction

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.

serde_shon's People

Contributors

chaosteil avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.