staticjsonv1
📘 StaticJSONv1 Module — Documentation
🇬🇧 English Documentation
🚀 Overview
StaticJSONv1 is a Drupal module that provides a way to generate static JSON representations of selected Drupal entities. It allows:
-
Configuration of which entity types and bundles should be exposed as JSON.
-
On-demand retrieval of individual entity JSON via URL.
-
Compression of all generated JSON files into a ZIP archive.
-
Drush commands to generate and compress JSON data.
Note: This module does not rely on core JSON:API or RESTful endpoints; it produces static JSON exports under custom routes defined by the module.
🧩 Features
⚙️ Configuration
At /admin/config/system/settings, administrators can:
-
Select which entity types and bundles should have static JSON exports generated.
-
Define settings used by the JSON generator (e.g., fields to include).
📍 Routes
Route Purpose/staticjson/{bundle}/{id}
Returns the JSON for a specific entity (bundle + ID). Example: /staticjson/article/123
/staticjson/compress
Generates a ZIP file with all currently exported JSON files
Configuration UI
/admin/config/system/settings — Select entities to include
🛠 Drush Commands
Command Descriptionstaticjson:generate
Generates all JSON exports for the configured entities. Must have entities selected in the settings.
staticjson:compress
Creates a ZIP archive of all current JSON export files.
📌 Usage Examples
Retrieve JSON for an Entity
GET /staticjson/article/123
This returns a static JSON object representing the article entity with ID 123.
Generate All JSON
drush staticjson:generate
Generates static JSON files for all selected entity types and bundles.
Compress All JSON
drush staticjson:compress
Creates a ZIP containing all generated JSON files.
🧠 How It Works
-
User selects entity types and bundles in the config form.
-
Drush command (or internal process) iterates over selected entities.
-
JSON files are written to a directory (e.g.,
public://staticjson/...). -
The
/staticjson/...routes serve those files directly.
📦 Notes
-
Ensure the module has write permissions to the directory where JSON files will be stored.
-
This module is primarily designed for decoupled sites or static content generation workflows.
🇪🇸 Documentación en Español
🚀 Resumen
StaticJSONv1 es un módulo para Drupal que permite generar representaciones JSON estáticas de entidades seleccionadas. El módulo ofrece:
-
Configuración de qué tipos de entidad/bundles se van a exportar a JSON.
-
URLs personalizadas para obtener el JSON de una entidad.
-
Compresión de todos los JSON generados en un archivo ZIP.
-
Comandos Drush para generar y comprimir JSON.
Nota: Este módulo no usa JSON:API del núcleo de Drupal. Proporciona rutas propias para servicios JSON estáticos.
🧩 Características
⚙️ Configuración
La página de configuración en /admin/config/system/settings permite:
-
Seleccionar qué tipos de entidad y bundles exportar en JSON.
-
Configurar ajustes usados por el generador.
📍 Rutas
Ruta Descripción/staticjson/{bundle}/{id}
Devuelve el JSON de una entidad específica. Ej.: /staticjson/article/123
/staticjson/compress
Genera un ZIP con todos los JSON exportados
Interfaz de configuración
/admin/config/system/settings — Selección de entidades para exportar
🛠 Comandos Drush
Comando Para qué sirvestaticjson:generate
Genera todos los JSON de las entidades configuradas
staticjson:compress
Crea un archivo ZIP con todos los JSON actuales
📌 Ejemplos de Uso
Obtener JSON de una Entidad
GET /staticjson/article/123
Retorna el JSON estático de la entidad article con ID 123.
Generar Todos los JSON
drush staticjson:generate
Genera los archivos JSON de las entidades seleccionadas en la configuración.
Comprimir Todos los JSON
drush staticjson:compress
Crea un ZIP con todos los JSON generados hasta el momento.
🧠 ¿Cómo Funciona?
-
El usuario selecciona los tipos de entidad y bundles en la configuración.
-
El comando Drush (o proceso interno) recorre esas entidades.
-
Se escriben archivos JSON en un directorio accesible (por ejemplo,
public://staticjson/...). -
Las rutas
/staticjson/...sirven esos archivos directamente.
📦 Notas
-
Asegúrate de que Drupal tenga permisos de escritura en el directorio donde se guardan los JSON.
-
Este módulo está diseñado normalmente para sitios desacoplados o flujos de trabajo con contenido estático.