The
Grouped Data String (GDS) file format is a robust and fast way to
save arrays with string key:value pairs that can be
nested up to 222 levels deep, and to
load such data again. It works in a
similar way as
JSON but is
more efficient and faster.
I originally developed it in 2024 for my latest self-developed personal self-management and projects management suite, and use it as a
general-purpose solution since then.
It uses two
ASCII signal bytes for
recursively writing arrays to GDS files and reading GDS files back to arrays:
ASCII #29 = "Group Separator" [GS]
- separates key:value pairs as "key[GS] value"
- separates same-level value|key boundaries
by "value[GS][level]key"
where [level] is the character you get
when adding the level depth (0..222)
to the character code of "!"
(which comes right after the space character)
ASCII #31 = "Unit Separator" [US]
- escapes any [GS] in values as "[US]1"
- escapes itself in values as "[US]0"
Here is an
example implementation
in my own programming language
Eas
(see
E
→Molaskes.info/Eas):
— Eas codec:
— encoder:
— to Grouped Data String
ToGDS
d — the data to encode
l 0 — level (only used by recursion)
:
x CHAR:29 — ASCII "group separator"
z CHAR:31 — ASCII "unit separator"
@@ d
v @
? IS'ARRAY:v
v ToGDS:v l+1
\ — escape escapers and delimiters
v RXEDIT:v z z;0
v RXEDIT:v x z;1
/
o[o?] @@;x;" ";v
/
<< JOIN:o x;CHAR:33+l — ="!"+l
/
— decoder:
— from Grouped Data String
FromGDS
d — the GDS data string to decode
l 0 — level (only used by recursion)
:
x CHAR:29 — ASCII "group separator"
z CHAR:31 — ASCII "unit separator"
d SPLIT:d x;CHAR:33+l — ="!"+l
l +
@@ d
v SPLIT:@ x;" " 1
? v?=1 — unescape end values
v RXEDIT:v[0] z;1 x
<< RXEDIT:v z;0 z
/
o[v[0]] FromGDS:v[1] l
/
<< o
/