Function: extractJson()
Makaio Framework / utils / extractJson
Function: extractJson()
Section titled “Function: extractJson()”extractJson(
text):string
Defined in: ../../../packages/utils/src/extract-json.ts:12
Extract a JSON object from text that may contain surrounding content.
LLM responses often wrap JSON in markdown fences or prose. This function
finds the first { and last } in the text and returns the substring
between them (inclusive).
Returns the original text unchanged when no valid brace pair is found.
Parameters
Section titled “Parameters”string
Raw text potentially containing a JSON object
Returns
Section titled “Returns”string
Extracted JSON substring, or the original text if no braces found