What you expect back. Unchecked, exactly like JSON.parse;
defaults to unknown so the cast is your decision.
Any object with content and mediaType, such as a
ZcapSpecExample.
The parsed value.
If the media type has no object representation (for
example message/http or text/plain) — read example.content instead.
Parse an example's
contentinto a JavaScript value.Saves callers from having to care whether a given example is strict JSON or JSON-with-comments, and from pulling in a JSONC parser to find out. Most zcap-spec examples are annotated with
//commentary and so are not valid JSON —JSON.parse(example.content)throws on them, which is the trap this exists to remove.Handles
application/json,application/jsonc, and any+jsontype such asapplication/ld+json. Media-type parameters (; charset=utf-8) are ignored. Comments are stripped only if a direct parse fails, so a correctly-labelled document is never rewritten unnecessarily — and a mislabelled one still parses.