Use when generating or auditing any `<script type='application/ld+json'>` blocks, implementing structured data for articles, products, FAQs, breadcrumbs, or loc
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-json-ld-valid-b85f0824ae8b ,按照其中的说明把「json-ld-valid」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Invalid JSON-LD is silently ignored by Google — there are no error messages in search results, only the absence of rich results. Invalid structured data means no eligibility for rich results (stars, FAQs, breadcrumbs, etc.) that increase click-through rates.
@context: 'https://schema.org', and include all required properties for the chosen @typeFind all <script type='application/ld+json'> elements on the page. For each: (1) Attempt to parse the content as JSON — flag syntax errors. (2) Verify @context is set to 'https://schema.org'. (3) Verify @type is a valid schema.org type. (4) For the detected type, check required properties are present (e.g., Article requires headline, author, datePublished; Product requires name; FAQPage requires mainEntity). (5) Run through Google's Rich Results Test API if available.
JSON.parse() — fix any syntax errors (trailing commas, single quotes, missing brackets).@context is exactly "https://schema.org" (not "http://schema.org" or omitted).@type value against schema.org types.Google uses JSON-LD structured data to generate rich results — enhanced search result formats that include stars, images, expandable Q&As, and other features. Invalid JSON-LD is ignored entirely: no rich results are generated, and no error is reported to you. Only by testing with the Rich Results Test can you discover validation failures. Correct, complete JSON-LD is a prerequisite for rich result eligibility.
Extract all <script type='application/ld+json'> element contents. Run JSON.parse() on each — catch and report parse errors. Validate that @context equals 'https://schema.org'. Check @type against a whitelist of common valid types. For each type, validate required properties are present and non-empty. Report the first validation error found for each block.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/en/rules/seo/json-ld-valid