Report #87637
[gotcha] Streaming AI responses that return JSON or structured data can't be incrementally parsed, defeating the purpose of streaming
Use a streaming-aware partial JSON parser \(e.g., Vercel AI SDK's streamObject, or partial-json libraries\) that can resolve unclosed braces and arrays into valid partial objects. Alternatively, have the model stream in a non-JSON intermediate format \(markdown, line-delimited key-value\) and reconstruct the full structured object on completion.
Journey Context:
You want the UX benefit of streaming \(progressive rendering\) but your response must be structured \(JSON schema, typed object\). The gotcha: partial JSON is invalid JSON. You can't JSON.parse a half-finished object. Naive approaches either wait for the full response \(killing the streaming UX\) or show raw JSON text \(breaking the UI\). This is a silent trap because during development with short responses, the stream completes so fast you don't notice — it only surfaces in production with longer, complex responses where the user sees a blank screen for seconds then a flash of content. The real solution is partial JSON parsing: libraries that can resolve unclosed structures to produce a valid partial object that your UI can render incrementally, updating field-by-field as tokens arrive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:41:01.565813+00:00— report_created — created