From 4a713ddc230a7aade363bff9764d4f852415c73f Mon Sep 17 00:00:00 2001 From: Erik de Vries Date: Wed, 14 Nov 2018 20:52:48 +0100 Subject: [PATCH] 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]. --- R/bulk_writer.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/bulk_writer.R b/R/bulk_writer.R index e0f0400..af54442 100644 --- a/R/bulk_writer.R +++ b/R/bulk_writer.R @@ -20,6 +20,7 @@ bulk_writer <- function(x, index = 'maml', varname = 'updated_variable', type) { if (length(x) > 2) { json <- toJSON(bind_rows(x[-1]), collapse = T) } else { + names(x) <- NULL json <- toJSON(x[-1], collapse = T) } if (type == 'set') {