boilerplate_rds_to_json {boilerplate} | R Documentation |
Convert RDS Database to JSON
Description
Utility function to convert existing RDS databases to JSON format. Can convert a single file or batch convert all RDS files in a directory.
Usage
boilerplate_rds_to_json(
input_path,
output_path = NULL,
pretty = TRUE,
quiet = FALSE
)
Arguments
input_path |
Path to RDS file or directory containing RDS files |
output_path |
Path to save JSON files. If NULL, saves in same location as input with .json extension. |
pretty |
Pretty print JSON for readability? Default is TRUE. |
quiet |
Suppress messages? Default is FALSE. |
Details
This function is useful for migrating existing RDS-based databases to the more portable JSON format. JSON files are human-readable, work well with version control, and can be used across different programming languages.
Value
Invisible TRUE on success
See Also
boilerplate_migrate_to_json
for full migration workflow
Examples
# Create temporary directory for example
temp_dir <- tempfile()
dir.create(temp_dir)
# Create sample RDS file
sample_db <- list(methods = list(sampling = "Random sampling"))
saveRDS(sample_db, file.path(temp_dir, "methods_db.rds"))
# Convert single file
boilerplate_rds_to_json(file.path(temp_dir, "methods_db.rds"))
# Convert all RDS files in directory
boilerplate_rds_to_json(temp_dir)
# Convert to different location
output_dir <- tempfile()
dir.create(output_dir)
boilerplate_rds_to_json(temp_dir, output_path = output_dir)
# Clean up
unlink(temp_dir, recursive = TRUE)
unlink(output_dir, recursive = TRUE)
[Package boilerplate version 1.3.0 Index]