Skip to main content

Module json_ld

Module json_ld 

Available on crate features http and std only.
Expand description

JSON-LD transport, response, and HTML embedding support.

JsonLd contains valid JSON encoded so it is safe both as an application/ld+json response body and inside an HTML script type=“application/ld+json” data block. It deliberately does not implement JSON-LD expansion, compaction, context loading, or vocabulary validation.

The HTML serializer escapes every literal less-than sign as \u003c. HTML parses a script element’s raw text before considering its type, so an otherwise inert JSON-LD string containing a script end tag could terminate the element. The JSON escape preserves the string value while removing that HTML parser boundary.

Structs§

EmbeddedJsonLd
A valid JSON-LD data block borrowed from an HTML document.
ExtractJsonLd
A lazy iterator over JSON-LD data blocks embedded in HTML.
JsonLd
A valid, script-data-safe JSON-LD document.
JsonLdScripthtml
An HTML script type=“application/ld+json” data block.

Enums§

ExtractJsonLdError
Error yielded while extracting an embedded JSON-LD document.

Functions§

extract_from_html
Lazily extract embedded JSON-LD documents from an HTML string.