v2.8 JSON First-Class: resaltado de sintaxis, vista de árbol, estadísticas y descarga correcta (85/85 tests)#8
Merged
Conversation
El soporte JSON existente (validar, formatear, minificar, convertir)
se completa en las vistas:
- highlightJSON(): resaltado de sintaxis tokenizando el texto crudo
(maneja comillas escapadas). Claves .attr, strings .value, números
.tag, booleanos/null .comment — reutiliza los colores de los 5 temas
sin CSS nuevo. renderOutput detecta el tipo de salida por prefijo.
- jsonTreeHTML(): vista de árbol para JSON con objetos {} y arrays []
colapsables (details nativo), contador de claves/elementos por nodo
y hojas con su valor tipado.
- collectStatsJSON(): los KPIs de estadísticas (valores, claves,
profundidad) ahora también se pueblan al formatear/minificar JSON.
- Descargar usa extensión y MIME correctos: .json para salidas JSON,
.csv tras convertir a CSV, .txt para reportes de diff/XPath.
Tests: 8 nuevos — 85/85 pasando.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumen
Petición directa del mantenedor: al formatear JSON, que se vea resaltado y también en árbol. Desde v2.7 la app formatea, minifica y valida JSON, pero las vistas seguían siendo solo-XML: el JSON salía en texto plano y la vista Árbol mostraba un aviso de error. v2.8 completa el soporte.
🎨 Resaltado de sintaxis JSON
highlightJSON()tokeniza el texto crudo (maneja comillas escapadas\") y reutiliza las clases de color existentes — funciona en los 5 temas sin una línea de CSS nueva:.attr· strings →.value· números →.tag·true/false/null→.commentrenderOutputdetecta el tipo de salida por prefijo ({o[), igual que la conversión🌳 Vista de árbol para JSON
jsonTreeHTML(): objetos{ }y arrays[ ]colapsables con<details>nativo, contador de claves/elementos por nodo, hojas con su valor tipado (strings naranjas, números azules). Antes: «📊 Estadísticas para JSON
collectStatsJSON(): los KPIs (valores totales, claves, profundidad) ahora se pueblan al formatear/minificar JSON — antes quedaban en «–».💾 Descarga con extensión correcta
El botón Descargar siempre producía
.xmlcon MIMEapplication/xml, aunque la salida fuera JSON o CSV. Ahora:.json,.csv(tras convertir) o.txt(reportes de diff/XPath), con el MIME correspondiente.Tests
8 nuevos: tokenizador (clases por tipo, escape de HTML y comillas), árbol JSON (objeto, array, inválido), y 3 de UI (resaltado al formatear, árbol con salida JSON, estadísticas). El test del aviso de árbol se actualizó: ahora el aviso es solo para texto no parseable. 85/85 pasando.
Verificación en UI real
JSON anidado de prueba: 9 claves coloreadas, 3 strings, 2 números, 2 booleanos/null; árbol con 5 nodos colapsables y 7 hojas; KPIs 12 valores / 9 claves / profundidad 5.
Métricas
index.html: ~2177 líneas / ~83KB (límites: ~2500 / 100KB duro).🤖 Generated with Claude Code