14 unstable releases (4 breaking)

0.4.0 Aug 11, 2018
0.3.0 Jun 16, 2018
0.2.2 May 20, 2018
0.2.0 Feb 14, 2018
0.0.1 Jul 30, 2017

#35 in Encoding

Download history 1597/week @ 2018-05-19 1586/week @ 2018-05-26 2725/week @ 2018-06-02 2221/week @ 2018-06-09 1296/week @ 2018-06-16 1339/week @ 2018-06-23 1712/week @ 2018-06-30 1332/week @ 2018-07-07 1274/week @ 2018-07-14 1824/week @ 2018-07-21 1081/week @ 2018-07-28 1654/week @ 2018-08-04 1863/week @ 2018-08-11

7,167 downloads per month

Rusty Object Notation

Build Status Crates.io Docs Gitter

RON is a simple readable data serialization format that looks similar to Rust syntax. It's designed to support all of Serde's data model, so structs, enums, tuples, arrays, generic maps, and primitive values.

Example in JSON

{
   "materials": {
        "metal": {
            "reflectivity": 1.0
        },
        "plastic": {
            "reflectivity": 0.5
        }
   },
   "entities": [
        {
            "name": "hero",
            "material": "metal"
        },
        {
            "name": "moster",
            "material": "plastic"
        }
   ]
}

Notice these issues:

  1. Struct and maps are the same - random order of exported fields
    • annoying and inconvenient for reading
    • doesn't work well with version control - quoted field names
    • too verbose - no support for enums
  2. No trailing comma allowed
  3. No comments allowed

Same example in RON

Scene( // class name is optional
    materials: { // this is a map
        "metal": (
            reflectivity: 1.0,
        ),
        "plastic": (
            reflectivity: 0.5,
        ),
    },
    entities: [ // this is an array
        (
            name: "hero",
            material: "metal",
        ),
        (
            name: "monster",
            material: "plastic",
        ),
    ],
)

The new format uses (..) brackets for heterogeneous structures (classes), while preserving the {..} for maps, and [..] for homogeneous structures (arrays). This distinction allows us to solve the biggest problem with JSON.

Here are the general rules to parse the heterogeneous structures:

class is named? fields are named? what is it? example
no no tuple (a, b)
yes/no no tuple struct Name(a, b)
yes no enum value Variant(a, b)
yes/no yes struct (f1: a, f2: b,)

Specification

There is a very basic, work in progress specification available on the wiki page. A more formal and complete grammar is available here.

Appendix

Why not XML?

  • too verbose
  • unclear how to treat attributes vs contents

Why not YAML?

  • significant white-space
  • specification is too big

Why not TOML?

  • alien syntax
  • absolute paths are not scalable

Why not XXX?

  • if you know a better format, tell me!

License

RON is dual-licensed under Apache-2.0 and MIT.

MIT/Apache-2.0 license

Dependencies

Reverse deps