// Sesi Structured JSON Writer & Reader
// Demonstrates native, model-free structured JSON validation and formatting using structured_output.

show "⚙️ Constructing structured raw JSON content..."

let rawJson = "{\"projectName\": \"Sesi Developer Suite\", \"version\": \"1.2.0\", \"status\": \"active\"}"

show "⚡ Validating and parsing JSON string using structured_output natively..."

// Parse and validate the JSON string natively using structured_output on a single line!
let parsedRegistry = structured_output({projectName: string, version: string, status: string})(rawJson)

show "✅ Natively parsed object details:"
show "Project Name: " parsedRegistry["projectName"]
show "Version: " parsedRegistry["version"]
show "Status: " parsedRegistry["status"]

// Convert back to structured JSON and write to disk
let formattedJson = to_json(parsedRegistry)
write_file("registry.json", formattedJson)

show "💾 Wrote verified structured JSON to registry.json"
