(s: string, ctx: Traversal)
| 462 | }) |
| 463 | |
| 464 | const parseJson: Morph<string> = (s: string, ctx: Traversal) => { |
| 465 | if (s.length === 0) { |
| 466 | return ctx.error({ |
| 467 | code: "predicate", |
| 468 | expected: jsonStringDescription, |
| 469 | actual: "empty" |
| 470 | }) |
| 471 | } |
| 472 | try { |
| 473 | return JSON.parse(s) |
| 474 | } catch (e) { |
| 475 | return ctx.error({ |
| 476 | code: "predicate", |
| 477 | expected: jsonStringDescription, |
| 478 | problem: writeJsonSyntaxErrorProblem(e) |
| 479 | }) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | export const json: stringJson.module = Scope.module( |
| 484 | { |
no test coverage detected
searching dependent graphs…