Books object format A (My attempt at creating a human writeable serialization format)
src | ||
test | ||
.gitignore | ||
BeefProj.toml | ||
BeefSpace.toml | ||
LICENSE | ||
README.md |
About
Bofa is a format for serializing and deserializing data in a human readable way.
This implementation of it is written in the Beef language.
The Syntax itself is relativly easy to understand and write, while also being relativly short,
since alot of unecessary symbols from things like json are removed.
Syntax
(
#Single line comments
stringValue "This is a string"
multiLine '
Any multi line
Strings
can go in here
'
boolean true
booleanOther false
number 4543.54
# This is a double internally
Arrays [
"One line"
"Another line"
"Even more lines"
]
Object (
ArrayInObject [
"Hello"
]
)
)
Usage
//Deserialize a Type T using the BofaParser<T> generic
BofaParser<ExampleDeserialize> parser = scope .();
String input = """
(
value "This is a string"
)
""";
var value = parser.Deserialize(.. ExampleDeserialize .(), input);
//Serializing is similarly simple and will directly output to the string buffer
BofaParser<ExampleSerialize> parser = scope .();
var buffer = parser.Serialize(ExampleSerialize , .. scope .());
//A non generic way is supported via the static parse method of BofaParser
class BofaParser -> public static Result<void, StringView> Parse(StringView text, Bofa object)
//This outputs a bofa object that can then be mapped as required
/*
When using the BofaParser<T> it will by default only use public fields that are of a specific supported type:
String, float, double, int, int8, int16, int32, int64, bool, Dictionary<String, T>, List<T> and Subclasses
[BofaInclude] and [BofaExclude] can be used to include private fields or to exclude public fields
[BofaAlias("NameOfField")] can be used to map names
*/