Saltar al contenido
Skillpedia
Programación general75 mil · #2907

json-safety

Qué hace

Esta skill revisa el código que lee JSON de APIs, del almacenamiento del navegador o de los usuarios, y se asegura de que los errores de lectura se manejen. Es para desarrolladores que trabajan con datos externos.

Cuándo usarla

  • ✓Cuando tu app se bloquea después de recibir una respuesta de API mal formada.
  • ✓Cuando un valor guardado en el navegador se corrompe y rompe la página.
  • ✓Cuando tu código usa datos analizados sin comprobar su forma.

Link de la skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/json-safety/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/json-safety/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Puedes hacer que el análisis de mi JSON sea seguro, por si los datos llegan mal formados?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente encuentra las llamadas a JSON.parse y comprueba que cada una esté envuelta en manejo de errores y que el resultado se valide antes de usarlo. Puede sugerir una biblioteca de validación de esquemas para datos externos.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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

Preguntas frecuentes

¿Qué pasa cuando falla el análisis de JSON?

La skill indica que JSON.parse lanza un error de sintaxis, que bloqueará la app si no se captura.

¿Por qué validar los datos analizados?

La skill indica que detecta formas inesperadas en el momento del análisis, en lugar de provocar errores más tarde.

¿Qué bibliotecas se mencionan?

La skill menciona Zod y Valibot como validadores con tipos seguros para datos externos.

Detalles

Descripción original del autor

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.

repo: thedaviddias/Front-End-Checklist

Popularidad

Estrellas en GitHub
75 mil
Posición en el ranking
#2907
Licencia
MIT
Actualizada
31/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas