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
Same example in RON
Scene
Note the following advantages of RON over JSON:
- trailing commas allowed
- single- and multi-line comments
- field names aren't quoted, so it's less verbose
- optional struct names improve readability
- enums are supported (and less verbose than their JSON representation)
RON syntax overview
- Numbers:
42
,3.14
,0xFF
,0b0110
- Strings:
"Hello"
,"with\\escapes\n"
,r#"raw string, great for regex\."#
- Booleans:
true
,false
- Chars:
'e'
,'\n'
- Optionals:
Some("string")
,Some(Some(1.34))
,None
- Tuples:
("abc", 1.23, true)
,()
- Lists:
["abc", "def"]
- Structs:
( foo: 1.0, bar: ( baz: "I'm nested" ) )
- Maps:
{ "arbitrary": "keys", "are": "allowed" }
Note: Serde's data model represents fixed-size Rust arrays as tuple (instead of as list)
Quickstart
Cargo.toml
[]
= "0.8"
= { = "1", = ["derive"] }
main.rs
use ;
Tooling
Editor | Plugin |
---|---|
IntelliJ | intellij-ron |
VS Code | a5huynh/vscode-ron |
Sublime Text | RON |
Atom | language-ron |
Vim | ron-rs/ron.vim |
EMACS | emacs-ron |
Specification
There is a very basic, work in progress specification available on the wiki page. A more formal and complete grammar is available here.
License
RON is dual-licensed under Apache-2.0 and MIT.
Any contribution intentionally submitted for inclusion in the work must be provided under the same dual-license terms.