Anondata: A sub-system of full Anonlang that doesn't have any executable code. This is meant to be the replacement for JSON when working in Anonlang.
Conversion between JSON and Anondata is trivial. The key-value paradigm is still there, but with less boilerplate (no quotes needed for keys). One major difference is that Anonlang uses the concept of 'group' as a data structure, which is like a combination of JSON's 'object' and 'array'.
Here's what some sample Anondata looks like:
alias data = [
menu [
id 'file'
value 'File'
popup [
menuitem [
[value 'New', onclick 'CreateNewDoc()']
[value 'Open', onclick 'OpenDoc()']
[value 'Close', onclick 'CloseDoc()'] ]
]
]
]
The same data expressed as JSON:
string data = {"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
Using an AnondataParser, parsing would be simpler (require less code), faster (less tokens and size), easier to type (use square-brackets and single-quote), arguably more human-readable (don't need extra quotes).
In fact, only use the parser if you need to stream the data. Otherwise, in Anonlang, you can use load data
and have each of the fields can just be simply accessed as something like data.menu
and data.menuitem
.