IndexOf not working on parsing JSON results from Twitter

I am using jQuery to parse the JSON result from Twitter.

Then I do a check against the returned results to see if they contain a double quote.

$.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 returned tweet contains a double quote.

I also tried using:, indexOf("\"");and that didn't work either.

Any idea what I can do wrong? Perhaps this is an encoding problem?

+3
source share
2 answers

The Twitter API returns double quotes as &quot;. As an example, open the answer to this request: http://search.twitter.com/search.json?q=foo .

So you need to use tweet.text.indexOf('&quot;').

+3

, . % 22, ? , tweet.text , ? , .

+1

All Articles