Reputation: 39395
I'm attempting to debug my web application with FireFox3. However, when a JSON feed comes from my application, Firefox wants to open up the "application/json" in a new program. Is there a way to configure FireFox3 to handle JSON like regular text files and open up the JSON in the current tab?
Thanks.
Upvotes: 20
Views: 11334
Reputation: 7066
The JSONView Firefox extension is really nice.
It formats, highlights, etc...
The only drawback is that it requires the mime type to be set to "application/json"
.
But it is not really a drawback for you, because based on your "answer" (which shouldn't be an answer) your problem is that the mime type is "application/json"
and as a result Firefox doesn't know what to do with it and downloads it instead of displaying.
(source: mozilla.net)
Upvotes: 19
Reputation: 161
This is a bit of an old question, but I discovered that Rails' respond_to method (at least as of 3.1) can be persuaded to render in a particular format by adding the query param 'format' to the resource in question. For example:
In the controller:
def show
@object = Object.find(params[:id])
respond_to do |format|
format.html
format.json { render json: @object }
end
end
In the browser:
/object/1 # => renders as html
/object/1?format=json # => renders as json
/object/1.json # => also renders as json
No change to the rails app is necessary to cause this to happen. It's Like Magic.
Upvotes: 0
Reputation: 32063
Try the Open in browser extension.
[edit 30.05.2010 - updated the link]
Upvotes: 14
Reputation: 1660
Having JSON sent with an application/json mimetype is correct and changing that would be wrong.
text/javascript is considered obsolete.
Upvotes: 0
Reputation: 43804
I would just use Firebug - it'll let you drill down into a JSON object on its own, along with its other hundred useful features.
Upvotes: 2
Reputation: 3878
Consider using a MIME type of text/javascript instead of application/json
Upvotes: 3
Reputation: 7388
I would look into the preferences > applications list. What application is targeted for "application/*" ?
Apart from that, are you using FireBug? Absolutely essential, since you can look at the headers and response content within the network view.
Upvotes: 3
Reputation: 9300
What is the content-type of the Json feed. Sounds like it may be some sort of application instead of text.
Change the content type of the feed to something that is text based and FireFox will no longer try to open it in another program.
Upvotes: 1