Skip to content

JSON File

NebelFox edited this page Feb 19, 2022 · 3 revisions

File structure

Serializer and BoxSerializer accept json files of specific structure:

{
    "styles": {
        "style-1-name": {
            /*style definition*/
        },
        "style-2-name": {
            /*style definition*/
        }
    },
    "boxes": {
        "box-1-name": {
            /*box definition*/
        },
        "box-2-name": {
            /*box definition*/
        }
    }
}

boxes accepts named Box objects, styles - named Style objects

As you may notice, both styles and boxes properties have similar semantics.

Names, given to definitions, are used to retrieve them from deserializers and allow inheritance.

Example

sample.json

{
    "styles": {
        "style": {
            "dialogue.greeting": "Just to fill the style"
        }
    },
    "boxes": {
        "box": {
            "commands": [
                "command"
            ]
        }
    }
}

Program.cs

using System;
using System.Collections.Generic;
using Verbox;
using Verbox.Text.Serialization;

var serializer = new Serializer();
serializer.Deserialize("sample.json");

var builder = serializer.Boxes["box"]
             .Style(seriaizer.Styles["style"]);
Clone this wiki locally