mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-21 15:42:58 +01:00
Answer architecture round 1: the reader returns its refusals and owns its stack, a decision and a test keep JSON.parse out, item 83 filed, the scoring run recorded
This commit is contained in:
@@ -65,9 +65,10 @@ function carriedJson(node: AdfNode, spelled: object, spelling: JsonSpelling, pat
|
||||
function readCarriedJson(raw: string, spelling: JsonSpelling, levels: number, type?: string): Read<AdfNode> {
|
||||
const wayOut = type === undefined ? directiveEscape : fenceEscape(type)
|
||||
const parsed = parseJsonText(raw)
|
||||
if (parsed === undefined) return { fault: malformedDirective(`the opaque carry holds invalid JSON; ${wayOut}`) }
|
||||
if (parsed.refusal !== undefined) {
|
||||
return { fault: parsed.refusal === 'syntax' ? malformedDirective(`the opaque carry holds invalid JSON; ${wayOut}`) : unsupportedNodeShape('the opaque carry holds a number JSON cannot spell') }
|
||||
}
|
||||
const { value } = parsed
|
||||
if (!isJsonValue(value)) return { fault: unsupportedNodeShape('the opaque carry holds a number JSON cannot spell') }
|
||||
const typed = type === undefined || type === '' ? { value } : typedValue(value, type)
|
||||
if (typed.fault !== undefined) return typed
|
||||
const held = typed.value
|
||||
|
||||
Reference in New Issue
Block a user