Skip to content

JSON Schema

Edit the JSON Schema on the left and the form regenerates on the right — no compiled model required. Alongside the standard keywords ($ref, allOf, if/then, dependentRequired, enum, format…), Borm reads a small set of x- extensions for the UI intent JSON Schema cannot express: widgets, layout, conditional visibility and wizard steps. Export (round-trip) writes the whole thing back out, conditions and steps included.

Schema
The form it becomes
Event registration

View source
@page "/json-schema"

<textarea @bind="_json" @bind:event="oninput"></textarea>
<button @onclick="Rebuild">Apply schema</button>
<button @onclick="ExportRoundTrip">Export (round-trip)</button>

@if (_schema is not null)
{
    <BormView @key="_version" Definition="_schema" Data="_data"
              OnValidSubmit="HandleSubmit" SubmitText="Submit" ShowErrorSummary="true" />
}

@code {
    private BormDefinition? _schema;
    private Dictionary<string, object?> _data = new();
    private int _version;
    private string? _error;

    private void Rebuild()
    {
        // TryImport reports a malformed document instead of throwing — the shape you want behind
        // a "paste your schema here" editor.
        if (BormJsonSchemaImporter.TryImport(_json, out var schema, out _error))
        {
            _schema = schema;
            _data = new Dictionary<string, object?>();
            _version++;
        }
    }

    private void ExportRoundTrip()
    {
        if (_schema is null) return;
        // Conditions, wizard steps, layout and widget choices all survive the round-trip.
        _json = BormJsonSchemaExporter.Export(_schema);
    }
}
An unhandled error has occurred. Reload 🗙