JSON-LD is a way to express structured data using JSON and linked-data concepts. Web pages often include it in a <script type="application/ld+json"> element to describe entities such as articles, products, events, or organizations.
Extracting JSON-LD
Locate the script element, parse its text as JSON, and inspect the @type and fields before mapping it to your schema. A page can contain multiple JSON-LD blocks or use an @graph array, so do not assume there is one object with one predictable shape.
Structured data is supplied by the page author and may be missing, stale, or inconsistent with visible content. Validate important values against the page and preserve the source URL. Search engines may use structured data under their own rules; its presence does not guarantee a rich result.
When parsing fails, save the exact script text for diagnosis. HTML entities, trailing commas, or a site-specific format can explain why a generic JSON parser rejects it.
Leave a Reply