GithubHelp home page GithubHelp logo

ron's Introduction

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": "monster",
            "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!

Tooling

Sublime Text: https://packagecontrol.io/packages/RON

Vim: https://github.com/ron-rs/ron.vim

License

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

ron's People

Contributors

torkleyy avatar bors[bot] avatar kvark avatar ebkalderon avatar victorkoenders avatar rhuagh avatar divinegod avatar fengalin avatar vessd avatar matklad avatar eijebong avatar xaeroxe avatar explojoe avatar nvzqz avatar pyfisch avatar memoryruins avatar gui1117 avatar

Watchers

 avatar James Cloos avatar  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.