I am trying to convert the following jquery code into a string that I can pass into a function in R:
function main() {
return join(
Events({
from_date: '2016-09-01',
to_date: '2016-12-01',
event_selectors: [{selector: 'event["event.name"]=="Page
Viewed"'}]
}),
People({
user_selectors: [{selector: 'user["Is Test"]==false'}]
}),
{type:'left'})
}
Since the query includes both single and double quotes, I can't simply wrap it in whichever one isn't present.
I have tried simply wrapping it into double quotes and then using escape characters for the double quotes inside the query, as shown below:
"function main() {
return join(
Events({
from_date: '2016-09-01',
to_date: '2016-12-01',
event_selectors: [{selector: 'event[\"event.name\"]==\"Page
Viewed\"'}]
}),
People({
user_selectors: [{selector: 'user[\"Is Test\"]==false'}]
}),
{type:'left'})
}"
But the problem is that when I run that string in R the escape characters actually show up, and I need to pass the original, untainted query into the 'mixpanelJQLQuery()' function in the 'RMixpanel' library.
Any suggestions?
You can assign your function to a variable and then just simply concat it with an empty string, doing it like:
var myFunction = function main() { /* your code here */ }
var stringifiedFunction = '' + myFunction;
Fiddle here.
Hope it helps. :)
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.