跳到正文
cccskills
免费在 GitHub 公开中文介绍

json-safety

检查JavaScript读取API响应或存储数据时的JSON处理,补充无效输入的异常处理,并在使用解析结果前验证数据结构,避免后续处理出错。

原文查看原文说明

Use when reviewing scripts, client components, bundles, or runtime behavior related to Parse JSON safely with error handling. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

AI 评分100分/ 100查看安装方法

适用场景

  • 检查API响应的JSON解析
  • 处理localStorage中的损坏数据
  • 访问属性前验证数据结构
  • 了解Zod或Valibot的适用场景

中文介绍

功能

这项技能检查JavaScript中的JSON读取逻辑,补充对无效输入和意外数据结构的处理。它会查找JSON.parse()调用,检查是否使用try/catch捕获异常,以及使用解析结果前是否验证了数据结构。检查对象包括API响应、localStorage中保存的值和用户输入的数据,并会指出及修正具体的问题代码。

适用场景

适合收到损坏的JSON后页面处理停止,或因缺少必要属性而在后续处理中报错的情况。代码审查时,也可以用它检查外部数据的接收方式,分别确认解析过程和解析后数据的使用是否存在问题。

使用示例

  • “请检查这个文件中的JSON.parse()调用,添加异常处理和数据结构验证。”
  • “请解释哪些情况下适合使用Zod或Valibot验证外部数据。”

注意事项

能否作为JSON解析,以及是否符合所需的数据结构,需要分别检查。原文提到使用Zod或Valibot验证外部数据,但并未将安装某个特定库列为必要条件。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

客观评估

AI 仅根据 SKILL.md 的内容,从 4 个方面进行了评估。星标数和热度不计入评估。

指令清晰度能否看出何时使用、做什么
A良好明确要求检查JSON.parse()的异常处理,并在使用前验证数据结构。
步骤具体性步骤、输入输出和示例是否具体
A良好给出了查找所有调用、检查try/catch及添加数据结构验证的步骤。
安全性发送数据、删除文件、执行命令等是否有说明
A良好修改范围是为目标代码添加异常处理和验证,未指示外部发送或读取凭据。
安装难易度所需工具和 API 密钥是否少且有说明
A良好面向JavaScript代码,未要求API密钥、付费服务或特定库。

总分按每项 A=25 分、B=15 分、C=5 分相加。 由 AI(OpenAI Codex)于 2026年10月23日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(2)

  • SKILL.md2.0 KB
  • references/rule.md4.0 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Parse JSON safely with error handling

JSON.parse() on invalid input throws a SyntaxError that will crash your application if uncaught. API responses, localStorage values, and user-provided data can all be malformed. Safe parsing with validation catches these errors at the point of parsing, not deep in your application logic when a missing property causes an unexpected error.

Quick Reference

  • JSON.parse() throws a SyntaxError on invalid input — always use try/catch
  • Validate the shape of parsed data before accessing its properties
  • JSON.stringify() can return undefined for values that can't be serialized
  • Use a type-safe parser (Zod, Valibot) for data from external sources

Check

Find all JSON.parse() calls in this file and check whether each one is wrapped in try/catch and whether the result is validated before use.

Fix

Add try/catch error handling to all JSON.parse() calls and add shape validation to protect against unexpected data structures.

Explain

Explain why JSON.parse can throw, what safe JSON parsing looks like, and when to use schema validation libraries.

Code Review

Review scripts, client components, and browser execution paths related to Parse JSON safely with error handling. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/json-safety

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

404-page

免费

Create and review custom 404 pages that help visitors recover from broken or moved links through search and navigation. Check the rendered page and HTTP response so missing content returns a proper 404 status.

中文简介正在准备中。当前显示英语简介。

  • Creating a helpful custom 404 page
  • Adding search and navigation for broken links
  • Checking missing pages that return HTTP 200
thedaviddias/Front-End-Checklist7.5万2026年10月6日 更新

Audit or create a dedicated About page that explains a website’s purpose and identifies its people or organization. Review the rendered output and supporting information, including expertise and contact details, to find gaps.

中文简介正在准备中。当前显示英语简介。

  • Reviewing a website’s About page
  • Creating a page about the organization and its mission
  • Checking how operator information appears in rendered output
thedaviddias/Front-End-Checklist7.5万2026年10月6日 更新

accessibility-testing

免费有简介AI 评分 80分

为页面和共用组件添加自动无障碍测试,检查现有测试的覆盖缺口,并将检查接入持续集成流程,以发现结构、属性问题及修改引入的新问题。

  • 检查共用组件的测试覆盖范围
  • 为页面交互测试添加无障碍检查
  • 在持续集成中运行无障碍检查
thedaviddias/Front-End-Checklist7.5万2026年10月6日 更新

accessible-authentication

免费有简介AI 评分 90分

检查从登录、多因素认证到账户恢复的完整流程,找出禁止粘贴、验证码必须手动输入等使用障碍,并协助改进认证方式。

  • 检查完整登录流程的无障碍性
  • 确认验证码粘贴与自动填充
  • 检查密码重置与账户恢复流程
thedaviddias/Front-End-Checklist7.5万2026年10月6日 更新

Review form errors, success messages, and live updates so screen reader users receive important notifications. Check the HTML delivered to the browser, announcement settings, display duration, and dismissal controls, then identify specific elements that need changes.

中文简介正在准备中。当前显示英语简介。

  • Reviewing form error announcements
  • Checking success message display duration
  • Auditing live update notifications
thedaviddias/Front-End-Checklist7.5万2026年10月6日 更新

Review HTML tables so screen reader users can understand how headers and data relate. Check header markup, table descriptions, and merged cells, then identify specific fixes and ways to verify them.

中文简介正在准备中。当前显示英语简介。

  • Reviewing tables for screen reader accessibility
  • Checking header relationships in tables with merged cells
  • Reviewing table patterns in a design system
thedaviddias/Front-End-Checklist7.5万2026年10月6日 更新

查看 thedaviddias 的全部技能

报告此技能的问题