Skip to content
KajayDocs
StartSDK neutral

Run Kajay in .NET

Install Kajay.Core, parse a definition, and run a native headless survey session.

1. Parse a definition

SurveyDefinition.Parse validates schema compatibility, preserves recoverable author diagnostics, and returns an immutable definition that can create independent survey sessions.

Program.cscsharp
using Kajay;

const string json = """
{
  "schemaVersion": 1,
  "pages": [{
    "name": "feedback",
    "elements": [{ "type": "text", "name": "email", "isRequired": true }]
  }]
}
""";

SurveyDefinitionParseResult parsed = SurveyDefinition.Parse(json);
foreach (DefinitionDiagnostic diagnostic in parsed.Diagnostics)
{
    Console.WriteLine($"{diagnostic.Severity}: {diagnostic.Code} at {diagnostic.Path}");
}

Survey survey = parsed.Definition.CreateSurvey();
survey.SetValue("email", KajayValue.From("person@example.com"));
SurveyAdvanceOutcome outcome = await survey.AdvanceAsync();

2. Run the survey

Set answers with KajayValue, inspect typed questions when a host needs presentation metadata, and use the asynchronous navigation methods whenever configured validation or host I/O can run.

3. Keep ownership explicit

A definition is immutable and reusable. Each CreateSurvey call creates one mutable session with one logical owner; do not mutate the same survey concurrently.

Where to go next

Persist portable state with Response Snapshots, then connect host services through hosting adapters.