Here’s a sketch for a brand-new “flat” text serialization format—call it Leaf (Leaf-Only Entities)—that combines:
• one-per-line simplicity
• a minimum of punctuation
• arbitrary nesting (via dotted keys)
• optional, in-line type hints
• comma-lists for arrays
• metadata and comments
1. Core Ideas
- One key-value per line.
- Dotted-key paths represent nesting—no braces or indentation.
- Type hints (optional) let you round-trip e.g. ints, floats, booleans, dates.
- Comma-separated lists for arrays.
- “@”-lines for file-level metadata, “#” for comments.
- Streaming-friendly: you never need to buffer the whole document.
2. Syntax
Each non-comment line is either
• a metadata record:
@=
• or a data record:
[:<type_hint>]=
where
• path = components joined by “.” (letters, digits, “_”):
user.address.street
• type_hint (optional) ∈ { i (int), f (float), b (bool), d (date), s (string) }
(default is string)
• value
– if comma-separated → array of items of type_hint (no nested lists)
– else → scalar
Comments start with “#” and run to end-of-line.
3. Example
# Leaf demo: a minimal user profile
@format=Leaf-1.0
@source=“user-db‐export”
user.id:i=42
user.name=“Alice Wonderland”
user.age:i=30
user.verified:b=true
user.score:f=1234.56
# an address
user.address.street=“123 Main St.”
user.address.city=“Springfield”
user.address.zip:i=98765
# array of tags
user.tags=admin,editor,api-user
# date fields
user.signup:d=2023-06-01
user.last_login:d=2023-06-10T14:23:00Z
Parsing this you get a tree:
{
"user": {
"id": 42,
"name": "Alice Wonderland",
"age": 30,
"verified": true,
"score": 1234.56,
"address": {
"street": "123 Main St.",
"city": "Springfield",
"zip": 98765
},
"tags": ["admin","editor","api-user"],
"signup": "2023-06-01",
"last_login": "2023-06-10T14:23:00Z"
},
"@meta": {
"format": "Leaf-1.0",
"source": "user-db‐export"
}
}
4. Advantages
• Human-readable: every datum lives on its own line
• Flat: no braces/bracket nesting—dotted keys do the hierarchy
• Streaming: parse or emit record by record
• Type-safe: optional hints preserve ints, floats, bools, dates
• Arrays: built-in comma lists without extra syntax
• Metadata+Comments: simple conventions for docs and file tags
5. Possible Extensions
• Support base64 binary:
image.data=b64,JVBERi0xLjMg…
• Reference/link syntax:
item.ref->other.id
• Value escaping rules for “=” or commas
Would something like Leaf fit your use-case? Any tweaks you’d make to the syntax or feature-set? 🍃