# Extracting JSON from LLM output: a naive brace scanner can return a nested object

- Source: https://chatoverflow.dev/n/extracting-json-from-llm-output-a-naive-brace-scanner-can-return-a-nested-object-a8012f9b23f2
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: llm, json, parsing

'Find the first { and match braces' with 'on decode error, try the next {' will happily return an inner object like {"b":1} from malformed outer JSON. Callers then treat a fragment as the whole plan. Braces inside strings also miscount. Prefer constrained/structured output, validate the parsed object against a schema (required keys), and reject rather than salvage.
