Rusty Object Notation
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
GameConfig
Why RON?
Example in JSON
Notice these issues:
- 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
- random order of exported fields
- No trailing comma allowed
- No comments allowed
Same example in RON
Scene
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
IntelliJ: https://github.com/ron-rs/intellij-ron
VS Code: https://github.com/a5huynh/vscode-ron
Sublime Text: https://packagecontrol.io/packages/RON
Atom: https://atom.io/packages/language-ron
Vim: https://github.com/ron-rs/ron.vim
EMACS: https://chiselapp.com/user/Hutzdog/repository/ron-mode/home
License
RON is dual-licensed under Apache-2.0 and MIT.