json-safety
できること
このスキルは、APIやブラウザーの保存領域、ユーザーから読み込むJSONを扱うコードを確認し、解析エラーが適切に処理されているか確かめます。外部データを扱う開発者向けです。
使う場面
- ✓不正な形式のAPI応答を受け取った後にアプリが停止するとき。
- ✓ブラウザーの保存値が壊れてページが動かなくなるとき。
- ✓解析したデータの形を確認せずに使っているとき。
スキルのリンク
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/json-safety/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“JSONの形式が不正な場合にも備えて、私のJSON解析を安全にしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはJSON.parseの呼び出しを見つけ、それぞれがエラー処理で囲まれているか、使用前に結果が検証されているかを確認します。外部データにはスキーマ検証ライブラリを提案することがあります。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
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
よくある質問
JSONの解析が失敗すると何が起きますか?
このスキルによると、JSON.parseは構文エラーを投げ、捕捉されなければアプリが停止します。
解析したデータを検証するのはなぜですか?
このスキルによると、後でエラーが起きるのではなく、解析の時点で想定外の形を見つけられます。
どのライブラリが挙げられていますか?
このスキルは、外部データ向けの型安全なバリデーターとして、ZodとValibotに触れています。
詳細
作者による元の説明
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.
人気
- GitHubのスター
- 75k
- ランキング
- #2907
- ライセンス
- MIT
- 更新日
- 2026/10/31
コメント
- …
このリポジトリの他のスキル
frontendchecklist
75kコマンドラインツールを使って、フロントエンドのコードとライブページを、アクセシビリティ、速度、SEO、セキュリティに関する380以上のルールと照らし合わせて確認します。
frontend-checklist-global
75kフロントエンドのプロジェクトを、386のFront-End Checklistのルールすべてと照らし合わせて監査し、見つかった問題ごとに具体的な修正方法を示します。
404-page
75k見つからないページの画面に役立つリンクがあり、本物の404ステータスを返すかを確認し、迷った訪問者が目的のページを見つけられるようにします。
about-page
75kサイトの運営者が誰かを説明する、分かりやすいAboutページがあるかを確認し、訪問者と検索エンジンからの信頼を高めます。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。