Take the 2-minute tour ×

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

The Twitter API returns double-quotes as &quot;. 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('&quot;') instead.

share|improve this answer

Yes, check encoding. %22, maybe? Otherwise, console shows that tweet.text has the quotes, right? I can see no reason why your code wouldn't work.

share|improve this answer

Your Answer


