Books object format A (My attempt at creating a human writeable serialization format)
Find a file
2025-09-25 15:54:00 +02:00
src Initial Commit 2025-09-25 15:36:31 +02:00
test Initial Commit 2025-09-25 15:36:31 +02:00
.gitignore Initial commit 2025-09-17 19:16:39 +02:00
BeefProj.toml Initial Commit 2025-09-25 15:36:31 +02:00
BeefSpace.toml Initial Commit 2025-09-25 15:36:31 +02:00
LICENSE Initial commit 2025-09-17 19:16:39 +02:00
README.md Update README.md 2025-09-25 15:54:00 +02:00

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 
*/