R/getReadSaveObj.JSON.R

Defines functions getReadSaveObj.JSON

Documented in getReadSaveObj.JSON

#' @describeIn  getReadSaveObj JSON serializer 

getReadSaveObj.JSON <- function() {
    return(list(save = function(obj, filePath) {
        serObj <- jsonlite::serializeJSON(obj, pretty = T)
        cat(serObj, file = filePath, append = F)
    }, read = function(filePath) {
        file <- file(filePath, "r")
        expectedLines <- readLines(file, warn = F)
        close(file)
        unlink(file)
        return(jsonlite::unserializeJSON(expectedLines))
    }))
}
bnbsystems/ddt documentation built on May 24, 2019, 3:04 a.m.