I am trying to connect to the RubyGems API, but when I try to get the JSON I get an stange error.
Uncaught SyntaxError: Unexpected token :
Related... If you are not returning valid JSON you will see this error, JSONP aside.
For me I was
format.json { render :json => ActiveSupport::JSON.encode({:foo => true}) :status => :ok }
=>
{
'foo': true
}
When I should have been
format.json { render :json => ActiveSupport::JSON.encode([{:foo => true}]) :status => :ok }
=>
[
{
'foo': true
}
]