DMON (Dummiesman Object Notation. Dummiesman is my alt username) is my own little format I’ve made for data. When I noticed many Unity JSON parsers took a long time to parse, couldn’t parse properly, ignored or used invalid rules, etc I set out to make something that was suited for my needs : simple yet powerful
Sample of DMON and C# code accompanying it
DMON
species {
cat {
//…I was out of ideas okay? ![]()
legs = 4
description = “Cute, but can be terrifying!”
}
dog {
legs = 4
description = “A mans best friend”
}
}
pets {
midnight {
name = “Midnight”
species = “cat”
}
a_dog {
name = “Diego”
species = “dog”
}
}
LuaTable<object> dmon = DMON.Parse(System.IO.File.ReadAllText("exampledmon.txt"))
int petCount = dmon["pets"].Count
for(int i=0; i < petCount; i++){
string species = (string)dmon["species"][dmon["pets"][i]["species"]];
string speciesDsc = (string)dmon["species"][species]["description"];
Debug.Log("Pet " + i + " is a " + species +" and this species is described as " + speciesDsc);
}
Syntax requirements:
Opening a table:
tablename {
There MUST be a space between tablename and {, tablename must not contain a space
Closing a table:
To close a table simply use } as the only character on the line. If you don’t weight out opening and closing brackets, you will get a stack imbalance exception due to the internal DMON table stack being unbalanced.
Setting a value:
value = 0
value = 0.1
value = false
value = “hello”
There MUST be a space between value, =, and the set value (0,0.1, etc)
Comments:
Comments require their own line but can appear anywhere
use // for comments (see above)
Side note : There is no IEnumerator type thing for this, but you can enumerate by index. Each LuaTable has a Count property, so you can do this:
for(int i=0; i < table.Count; i++){
LuaTable<object> dmonTable = table[i];
}
This project wouldn’t be possible without Jashaszun for creating the base LuaTable class (Luatable equivalent in C#? - Stack Overflow)!
Hope you guys can get some use out of this ![]()
2217168–147567–DMON.zip (2.19 KB)