I’m using jQuery to parse a JSON result from Twitter.
I’m then performing a check against the returned results to see if they contain a double quotation mark.
$.getJSON(url + query, function(json) {
$.each(json.results, function(i, tweet) {
var result = tweet.text.indexOf('"');
if(result != -1) {
$("#results").append('<p>' + tweet.text + '</p>');
}
});
});
The result is always -1. Even if the tweet returned contains a double quot.
I also tried using: indexOf("\""); and that didn’t work either.
Any idea what I might be doing wrong? Is this an encoding issue perhaps?
The Twitter API returns double-quotes as
". As an example, check out the response for this query: http://search.twitter.com/search.json?q=foo.So, you’ll need to use
tweet.text.indexOf('"')instead.