You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ const data = extractJson<{ score: number }>(modelOutput);
39
39
-**Handles the real wrappers.** Markdown fences (`json` and bare ```), conversational prose before/after, and the JSON sitting bare in the text.
40
40
-**String-aware, never corrupts.** The scanner and the trailing-comma repair both respect string contents — a `}` or `,` inside `"a string value"` is left alone.
41
41
-**Conservative repair.** Removes trailing commas (the most common malformation); it will never rewrite your data.
42
+
-**Fixture-backed edge cases.** Public fixtures cover reasoning tags, fenced JSON, prose wrappers, trailing commas, top-level type expectations and no-JSON failures.
42
43
-**Two entry points.**`extractJson` throws on failure; `tryExtractJson` returns `{ found }`.
43
44
-**Zero dependencies**, ESM + CJS, fully typed.
44
45
@@ -82,6 +83,21 @@ extractJson('[1,2] then the answer {"a":1}', { expect: 'object' }); // { a: 1 }
82
83
83
84
The low-level pieces (`stripReasoning`, `fencedBlocks`, `balancedSpans`, `removeTrailingCommas`) are exported too.
84
85
86
+
## Fixture corpus
87
+
88
+
The package includes a small public corpus under [`fixtures/`](./fixtures):
89
+
90
+
-`deepseek-thinking-object.txt`
91
+
-`gemini-reasoning-array.txt`
92
+
-`prose-trailing-commas.txt`
93
+
-`expect-object-skips-array.txt`
94
+
-`no-json.txt`
95
+
- expected `tryExtractJson` outputs under `fixtures/expected/`
96
+
97
+
The tests read these files directly, so parser changes are checked against
98
+
stable, reusable examples. The fixtures are synthetic and safe for public CI:
99
+
they contain no prompts, secrets, user data or live provider responses.
100
+
85
101
## Related
86
102
87
103
-[`tool-schema`](https://www.npmjs.com/package/tool-schema) — turn a JSON Schema into a provider tool/function schema (define the shape you then extract).
0 commit comments