LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
← Build a tenant-safe MCP tool server & eval runner
BUILD → VERIFY → EXPLAIN · STEP 5 OF 6

Parse and enforce structured LLM responses

Validate types, required fields, enums, and reject unexpected keys.

UNDERSTAND

Bring these concepts with you

BUILD

Your implementation

  1. Implement parseStructuredResponse(rawText, schema) safely stripping clean code fences.
  2. Validate parsed JSON objects against schema.fields (required, type, enum) and throw on extra unexpected keys.
export function parseStructuredResponse(rawText, schema) {
  // Parse JSON strictly and verify required fields, types, enums, and allowed keys.
}
Need a hint?
  • Reject prose wrapped around JSON—only clean JSON or explicit fenced JSON should parse.
  • Reject unknown properties so injected keys like role: 'admin' cannot slip downstream.

Saved on this device · 0 / 6000 · Do not include passwords or private data.

VERIFY

Acceptance checks

From the folder containing your downloaded files, run:

node checks.mjs ./starter.mjs 5

This runs checks up to this step. Earlier steps must work first. Mark each result only after checking your implementation; the website does not run or grade it.

Record your attempt to enable the checklist and reference comparison.

Compare with the reference

Attempt the step first, then compare decisions and behavior. There can be more than one correct implementation.

EXPLAIN

Your interviewer asks

What is the risk of silently defaulting to empty values when JSON parsing fails 5% of the time?

Say your answer aloud, then record the trade-offs and evidence in your notes above.

LOCAL VOICE REHEARSAL

Rehearse your step walkthrough aloud

Target pacing: 02:00 · Stays in this browser only; never uploaded.

00:00/ 02:00
AlifBay Prep