ahmedabdelaal/filament-json-preview
Pros:
Infolist/Table components, aligning with Filament’s declarative UI paradigm. Ideal for admin panels requiring JSON inspection/editing (e.g., logs, configs, API responses).Cons:
jsoneditor config (e.g., themes, modes) isn’t exposed via PHP API—requires JS/CSS overrides or forking.JsonPreview::make('api_response')->searchable()).Form components with minor effort (e.g., via custom JsonEditor field), but not natively supported.vendor:publish for SVG icons may clash with existing Filament themes or custom assets.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| JSONEditor Bloat | Medium | Audit jsoneditor bundle size (~500KB minified). Lazy-load if critical for performance. |
| Filament Breaking Changes | High | Pin Filament version in composer.json (e.g., ^3.0). Monitor Filament’s deprecations. |
| Security | Low | JSONEditor defaults to safe modes (no eval/functions). Review if custom schemas enable unsafe input. |
| State Management | Medium | Large JSON edits may cause UI lag. Consider server-side pagination for nested data. |
tree, view) sufficient, or needed custom JS config?json_encode + <pre> tag suffice? Justify the ~500KB JS bundle.Infolist/Table components.Http::get()->json()).serialize/json_encode of Eloquent models).composer require ahmedabdelaal/filament-json-preview --dev
php artisan vendor:publish --tag=jsoneditor --ansi
JsonPreview::make('test')->searchable()).<pre> tags or third-party editors (e.g., Ace Editor) in one Filament resource.memory_get_usage() before/after).Infolist/Table components using JSON previews.JsonPreview for API responses >50KB").| Dependency | Version Check | Risk |
|---|---|---|
| Filament | `^2.0 | |
| PHP | ^8.0 (per Filament) |
Low |
| JSONEditor | v9.x (bundled) | Medium (JS conflicts) |
| Frontend Stack | Vite/Laravel Mix (for asset handling) | Low |
public/vendor/filament-json-preview to avoid collisions with Filament’s default assets.mix.version() or Vite’s asset hashing to mitigate cache issues.JsonPreview in Infolist for read-only scenarios (e.g., logs).Form components by creating a custom JsonEditor field (requires ~50–100 LOC).window.initJsonEditor = function() { ... }).dev branch.<pre> tag fallback for critical paths:
{{ json_encode($jsonData, JSON_PRETTY_PRINT) }}
->showNavigationBar(false) to reduce DOM complexity.| Scenario | Impact | Mitigation |
|---|---|---|
| Malformed JSON | UI crash | Add try-catch in PHP: json_decode($data, true) before passing to JsonPreview. |
| JSONEditor JS Error | Broken preview | Polyfill with a <pre> fallback. |
| Asset Loading Failure | Missing icons/editor | Verify public_path() and Vite config. |
| ** |
How can I help you explore Laravel packages today?