https://github.com/gilzoide/nested
A generic nested data structure file format, where data is formed by nested lists with both sequential data and key-value paired data.
https://github.com/gilzoide/nested
file-format lua nested-lists nested-structures serialization
Last synced: about 1 month ago
JSON representation
A generic nested data structure file format, where data is formed by nested lists with both sequential data and key-value paired data.
- Host: GitHub
- URL: https://github.com/gilzoide/nested
- Owner: gilzoide
- License: unlicense
- Created: 2020-06-02T22:50:56.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-08T14:42:43.000Z (over 2 years ago)
- Last Synced: 2025-02-13T22:19:17.427Z (3 months ago)
- Topics: file-format, lua, nested-lists, nested-structures, serialization
- Language: Lua
- Homepage:
- Size: 134 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Nested
A generic nested data structure textual format.Data is formed by nested lists with associated key-value paired data.
Each list can have any number of elements, either sublists or text values, and any number of key-value data.
Particularly, a list containing only sequential data would be like regular *lists* or *arrays* and
a list containing only key-value data would be like *maps* or *dictionaries*.## Format
- Whitespace, commas `,` and semi-colons `;` separates list nodes
- Any non-whitespace sequence that don't fall in any of the following rules
is a text value
- Parenthesis `()`, brackets `[]` or braces `{}` delimit a child list
- Starting single quotes `'`, double quotes `"` and backticks\`
delimit a single
text value that may contain otherwise special characters, like `()`, `[]`, `,`, `:` or `;`.
The quotation marks can be escaped by being doubled, so that the text `'one ''quoted'' phrase'`
content becomes `one 'quoted' phrase`, for example. Notice that quotation marks can
appear normally in the middle of text values, like `f'` or `double"quotes"`
- A mumber sign `#` starts a comment, so the rest of the line text is discarded.
To use `#` as the first character in a text value, the text must be quoted
- A colon `:` just after a text value marks a key-value data binding
with the just parsed text value being the key and the following node
being a value. To use `:` in a text value, the text must be quoted.
Notice that keys are always text, but values can be either text or nested lists.It's interesting to notice that valid [JSON](https://www.json.org) files are also valid **Nested** files,
although **Nested** does not enforce the same semantics for non-textual values like numbers and `null`, nor
text escape sequences.## Implementations
For now, there is an implementation in Lua. [Lua tables](https://www.lua.org/pil/2.5.html)
are exactly a representation of data with both sequential and key-pair values.Install it using [LuaRocks](https://luarocks.org/):
$ luarocks install nested
Or just copy `lua/nested.lua` into your Lua path and `require` it, the module has no dependencies.
There is also a Command Line Interface script for reading and reformatting nested data in the file `lua/main.lua`.
When installing with [LuaRocks](https://luarocks.org/), the CLI script is installed as the `nested` command.$ luarocks install nested-cli
## Documentation
[LDoc](https://github.com/lunarmodules/LDoc) based documentation for the Lua module is
available at [github pages](https://gilzoide.github.io/nested/) and can be generated with
the following command:$ ldoc lua/doc -d docs