Question

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.

Was it helpful?

Solution

Try the Open in browser extension.

[edit 30.05.2010 - updated the link]

OTHER TIPS

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.

JSONView

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.

Consider using a MIME type of text/javascript instead of application/json

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.

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.

Having JSON sent with an application/json mimetype is correct and changing that would be wrong.

text/javascript is considered obsolete.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top