From f7892d4e87f60ca04eaf6fcd287dfdb1807e42cf Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 1 Aug 2018 20:59:37 +0000 Subject: [PATCH] Updates the mongo-style raw encoding to match v2 of their spec. The "$binary" format has changed as of May 2017. Before, we had e.g. {"x" : {"$binary" : "//8=", "$type" : "00"}} and now we have e.g. {"x" : { "$binary" : {"base64" : "//8=", "subType" : "00"}}} Signed-off-by: Aaron Jacobs --- R/asJSON.raw.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/asJSON.raw.R b/R/asJSON.raw.R index fc7202e0..b6285bf3 100644 --- a/R/asJSON.raw.R +++ b/R/asJSON.raw.R @@ -6,7 +6,7 @@ setMethod("asJSON", "raw", function(x, raw = c("base64", "hex", "mongo"), ...) { # encode based on schema if (raw == "mongo") { type <- ifelse(length(attr(x, "type")), attr(x, "type"), 5) - return(asJSON(list(`$binary` = as.scalar(base64_enc(x)), `$type` = as.scalar(as.character(type))))) + return(asJSON(list(`$binary` = list(`base64` = as.scalar(base64_enc(x)), `subType` = as.scalar(as.character(type)))))) } else if (raw == "hex") { return(asJSON(as.character.hexmode(x), ...)) } else {