boilerplate_migrate_to_json {boilerplate} | R Documentation |
Migration Utilities for RDS to JSON Conversion
Description
Functions to help migrate from individual RDS files to unified JSON structure Migrate boilerplate Database from RDS to JSON
Usage
boilerplate_migrate_to_json(
source_path,
output_path,
format = c("unified", "separate"),
validate = TRUE,
backup = TRUE,
quiet = FALSE
)
Arguments
source_path |
Path to directory containing RDS files or single RDS file |
output_path |
Path where JSON files should be saved |
format |
Output format: "unified" (single JSON) or "separate" (one per category) |
validate |
Logical. Validate against JSON schema after conversion? Default is TRUE. |
backup |
Logical. Create backup of original files? Default is TRUE. |
quiet |
Logical. Suppress progress messages? Default is FALSE. |
Details
Comprehensive migration tool that converts existing RDS-based boilerplate databases to JSON format. Supports both unified (single file) and separate (multiple files) output formats with optional schema validation.
The migration process:
Scans source directory for RDS files
Creates timestamped backup if requested
Converts RDS to JSON format
Validates against schema if requested
Reports results and any issues
The "unified" format creates a single JSON file containing all categories, which is recommended for version control and collaborative workflows.
Value
List with migration results containing:
-
migrated
: Character vector of successfully migrated files -
errors
: List of any errors encountered during migration -
validation
: Validation results if validate=TRUE
See Also
boilerplate_rds_to_json
, validate_json_database
Examples
# Create temporary directories for example
source_dir <- tempfile()
output_dir <- tempfile()
dir.create(source_dir)
dir.create(output_dir)
# Create sample RDS file
sample_db <- list(
name = "Example Measure",
description = "An example for migration",
items = c("item1", "item2")
)
saveRDS(sample_db, file.path(source_dir, "measures_db.rds"))
# Migrate from RDS to JSON
results <- boilerplate_migrate_to_json(
source_path = source_dir,
output_path = output_dir,
format = "unified",
validate = FALSE
)
# Check results
if (length(results$errors) == 0) {
message("Migration successful!")
} else {
print(results$errors)
}
# Clean up
unlink(source_dir, recursive = TRUE)
unlink(output_dir, recursive = TRUE)