bulk_writer: setting names(x) <- NULL when there is only one value (list or otherwise) to be updated.

This is because R apply treats rows of single values as a matrix, while it treats rows containing lists as (named) list. This has the nasty result of getting subvalues when using to JSON. i.e. computerCodes.actors = [list, of, ids] becomes computerCodes.actors.ids = [list, of, ids].
master
Erik de Vries 6 years ago
parent 6bb8f9b635
commit 4a713ddc23

@ -20,6 +20,7 @@ bulk_writer <- function(x, index = 'maml', varname = 'updated_variable', type) {
if (length(x) > 2) { if (length(x) > 2) {
json <- toJSON(bind_rows(x[-1]), collapse = T) json <- toJSON(bind_rows(x[-1]), collapse = T)
} else { } else {
names(x) <- NULL
json <- toJSON(x[-1], collapse = T) json <- toJSON(x[-1], collapse = T)
} }
if (type == 'set') { if (type == 'set') {

Loading…
Cancel
Save