This works when I am dynamically querying by just one particular value of col but incase my col is an array eg: c("red","blue"), it is failing.
col<-"red"
pipe1 <- paste("{\"$match\":{\"color\":\"",col,"\"}}", sep = "")
query1 <- list(
mongo.bson.from.JSON(pipe1),
mongo.bson.from.JSON('
{
"$project" : {
"_id" : 0,
"Email":"$email",
"color":"$color" }
}'))
Any solutions? Using this to convert Json to dataframe in R
If col
is an array, like you say, then the string it produces wouldn't be valid JSON. I think it would be something like:
{"$match":{"color": "red", "blue" }}
When what you need is:
{"$match":{"color": ["red", "blue"] }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.