Learn R Programming

mpathsenser (version 1.2.3)

test_jsons: Test JSON files for being in the correct format.

Description

[Stable]

Usage

test_jsons(path = getwd(), files = NULL, db = NULL, recursive = TRUE)

Value

A message indicating whether there were any issues and a character vector of the file names that need to be fixed. If there were no issues, an invisible empty string is returned.

Arguments

path

The path name of the JSON files.

files

Alternatively, a character list of the input files.

db

A mpathsenser database connection (optional). If provided, will be used to check which files are already in the database and check only those JSON files which are not.

recursive

Should the listing recurse into directories?

Parallel

This function supports parallel processing in the sense that it is able to distribute it's computation load among multiple workers. To make use of this functionality, run future::plan("multisession") before calling this function.

Progress

You can be updated of the progress of this function by using the progressr::progress() package. See progressr's vignette on how to subscribe to these updates.

Examples

Run this code
if (FALSE) {
# Test all files in a directory
test_jsons(path = "path/to/jsons", recursive = FALSE)

# Test all files in a directory and its subdirectories
test_jsons(path = "path/to/jsons", recursive = TRUE)

# Test specific files
test_jsons(files = c("file1.json", "file2.json"))

# Test files in a directory, but skip those that are already in the database
test_jsons(path = "path/to/jsons", db = db)
}

Run the code above in your browser using DataLab