Markup Language, Grid-Based (MLGB)
parses sheets into a JSON.
MLGB grammer is defined recursively.
input of MLGB is a list of list of string.
by parsing top-left corner of input, the MLGB type is determined.
if first grid of first row is empty string, a special MLGB vlaue,
No value is returned.
Literal JSON value
if first row of input contains:
- only one element;
- first grid with non-empty string and second grid with empty string
the value is "Literal JSON value", which means: if the string itself is a valid JSON, parser will return as its JSON value. else, it would be the string as it is.
Special Literal JSON value
FALSE will be parsed as JSON value
TRUE will be parsed as JSON value
"1" will be parsed as string 1 instead of number 1, using similar value to represent number string.
"" will be parsed as empty string, instead of
if first grid of first row is not
#, it will be parsed as a JSON object.
if first grid of first row is
-, MLGB parser will scan through first column, if not all non-empty string are
-, it will be parsed as a JSON object.
first, an empty result JSON object will be constructed.
then, scan through the first column of input. when a non-empty string is found, it is considered as a MLGB JSON-Object key.
i_next be the index of row of this non-empty string and next non-empty string,
the MLGB value of (zero-index) range of row
[i_this, i_next) and column of
[1, last_column] will be the value of this key.
MLGB JSON-Object key
the key is a dot(
.)-separated key representing the path of JSON object. as a special case, solely one dot (
.) representing the current path.
One solely dot is very useful in some cases, more examples to be presented here.
value of three dots must be a valid JSON-Object value, and it would be merged with current return object. unless, the whole JSON-Object will be parsed as a
if the JSON-Object value is
No value, the key will not be added to the current result object.
if the key is already exists in result object, the value of this key will be overwritten.
if all non-empty values in first columns are
-, it is parsed as a JSON array.
a JSON-Array is parsed similarly to JSON-Object. A
No value element will not be appended to a JSON-array.
if first grid of first row is
#, it will be parsed as a "MLGB-Sharp".
__ to any keys in object or items (-) in array, the key or item will be not parsed. This is useful to prevent intermediate variables from being exported.
MLGB with multiple sheets in a spreadsheet file
Json in the first sheet will be used.
MLGB as a folder
A folder containing several spreadsheets or folders can be parsed as a Json object. There're 2 ways to merge Json across files.
(Default) An object will be returned, which contains each file's Json as value. The key is name of file.
.can be used.
A list will be returned, which contains each sheet as item in list in order. the list is sorted alphabetically.
.can be used. appending
to file's name to denote this approach.
MLGB resource could be registered to a MLGB server with key, which could be accessed by API externally. MLGB server parses MLGB folder or spreadsheet to Json object.
There're 2 kinds of link pointing to another part of file or rest of Internet in MLGB.
Link to another sheet in current spreadsheet file
Link to other part of Internet The general grammar is
endpoint: the URL which MLGB server provides, can be omitted when refering to resource in the same server
key: the key registered in server, could be omitted when refering to resource in the same key
path: path to your part of Json.
Note that link in 2. always starts with a
/, and always starts with
// when pointing to other servers.
MLGB and XML
MLGB has no plan to support XML.