Update. By looking at the Google translate API, it looks like the JSONP callback parameter is optional. Do not specify a callback and you will no longer have this problem. :)
http://code.google.com/apis/language/translate/v2/using_rest.html#WorkingResults
The best option:
, API Google, . JSON JSONP, pick.
:
API JSONP, , JSON, pick.
:
:
ruleset a60x494 {
meta {
name "jsonp-to-json-test"
description <<
jsonp-to-json-test
>>
author "Mike Grace"
logging on
}
global {
returnedJsonpAsString = 'handleResponse({ "data": { "responses": [ { "response": "successful" } ] } } );';
datasource googleApi <- "blah blah blah";
}
rule fix_jsonp_to_json {
select when pageview ".*"
pre {
cleanJson = returnedJsonpAsString.replace(re/^.*\((.*)\);/,"$1");
response = cleanJson.decode().pick("$..response");
}
{
notify("Response",response) with sticky = true;
emit <|
console.log(returnedJsonp);
console.log(cleanJson);
|>;
}
}
}