Documentation
¶
Overview ¶
Command jsonld extracts every JSON-LD block from a document and reports what is wrong with each one.
jsonld page.html block 1 at bytes 47..312 @type=BreadcrumbList ok block 2 at bytes 980..1024 @type=Product 2 problems missing "@context" "offers" is not an object or an array
It changes nothing. The document goes to standard output byte for byte, and the report to standard error, so it composes in a pipeline with programs that do rewrite.
The offsets are the point of doing this with a rewriter rather than a parser. A block's SourceLocation is counted from the first byte fed in, whatever the chunking, so a caller holding its own copy of the input can slice out exactly the bytes complained about. This program does that itself to report them, and the property is pinned in sourceloc_test.go rather than assumed here.
The JSON is parsed with encoding/json, which is the right tool for reading - unlike writing into a script, where its lack of "/" escaping makes it the wrong one.