nimgent/structured_output/jsonschema_parse
This page is generated from the module’s exported API and ## documentation comments.
Loose JSON extraction and partial JSON repair used by structured output.
Procedures
Section titled “Procedures”extractJson
Section titled “extractJson”A complete JSON value, or the first object/array after leading prose.
proc extractJson(s: string): JsonNode {.raises: [], tags: [ReadIOEffect, WriteIOEffect], forbids: [].}Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
fixJson
Section titled “fixJson”Close a prefix of JSON so parseJson can read it. Port of AI SDK fixJson.
proc fixJson(input: string): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
input |
string |
parsePartialJson
Section titled “parsePartialJson”Parse complete JSON, or a repaired prefix (AI SDK parsePartialJson).
proc parsePartialJson(s: string): tuple[value: JsonNode, state: PartialParse] {. raises: [], tags: [ReadIOEffect, WriteIOEffect], forbids: [].}Returns: tuple[value: JsonNode, state: PartialParse].
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
PartialParse
Section titled “PartialParse”Result of parsing or repairing a partial JSON value.
PartialParse = enum ppUndefined, ppSuccess, ppRepaired, ppFailed