Typed Object Notation | Specification | Data Formats
AKA, can we be simpler and more compact than JSON without sacrificing readability.
; This is a TYON document
title = "TYON Example" ; files are implicitly maps
list = [1 2 3]
map = (
first = John
last = Doe
age = 42
"favorite numbers" = [13 42]
)
; strings can contain any character except ", which is escaped as ""
string = "hello, this is a string
with some ""quoted text"" and
multiple lines"
; a type declaration specifies the keys for the type
/person = (first last age)
; a typed map matches the type keys to values in order
owner = /person (Mary Sue 36) ; first = Mary, last = Sue, age = 36
; a value of _ in a typed map means there is no corresponding value
employee = /person (Other _ 25) ; first = Other, age = 25
; a typed map can have extra key / value pairs
"with extra" = /person (First middle = D Last 21 address = "123 address")
; lists can also be typed, with the type applying to the children
typed-list = /person [
(John Doe 42)
(Mary Sue 36)
]
; types can be declared inline
points = /(x y z) [
(1 2 3)
(4 5 6)
(7 8 9)
]
; types can be overridden
people = /person [
(John Doe 42)
/(x y) (1 2) ; type overridden by the inline type
( ; key / value pairs supplied directly
a = 1
b = 2
c = 3
)
]
Typed lists and maps let you specify the keys once at the start of the collection.
JSON | TYON |
---|---|
|
|
Strings can span multiple lines, and everything is literal except for "
which is escaped as ""
JSON | TYON |
---|---|
|
|
TYON files are implicitly maps and do not require brackets.
Keys do not require quotes unless they contain breaking characters such as whitespace.
Commas are not used between items.
JSON | TYON |
---|---|
|
|
Recommended data formats for booleans, numbers, etc. are separate from the main specification, and are only made for easier interoperability between systems.
tyon [command]
format [files] Format specified files.
to-json [files] Convert files to JSON, the output file name is [input file name].json
validate [files] Validate specified files.
debug [files] Print debug information for the specified files.
help Print help information and exit.
version Print program version and exit.
The TYON CLI is implemented in Zig, last compiled with 0.12.0-dev.3033+031f23117.
You will need a build of Zig master to build the CLI.
git clone https://github.com/tyon-lang/tyon
cd tyon
zig build -Doptimize=ReleaseSafe