bhollis / jsonview

A web extension that helps you view JSON documents in the browser.
http://jsonview.com
MIT License
1.53k stars 227 forks source link

JSonview seem to not based on header but on url extension #80

Closed Geolim4 closed 9 years ago

Geolim4 commented 10 years ago

Hi, It seems that jsonview is based on the url extension, but you doesn't check if the provided contain a hash.

I am a developer (see my project named MVT), and currently writing a tool that will help me to check extensions related to the phpBB software.

I found a weird bug, that you can see yourself: If the url contain a hash that end with '.json' jsonview override the page CSS: http://mvt.geolim4.com/index.php?mod=MVT-test-MOD#composer.json

I think you have to check the url hash before handling js-view.css It may be * better* to add an option like: "Enable only when <application/json> header is provided".

Regards, Geolim4

bhollis commented 10 years ago

It seems that jsonview is based on the url extension, but you doesn't check if the provided contain a hash.

Nope, that's not how it works. It just looks to see if the Content-Type is application/json. You can check the documentation here: https://github.com/bhollis/jsonview

You may be thinking of the unofficial JSONView for Chrome? Loading the URL you provided looks fine to me.

Geolim4 commented 10 years ago

I'm using firefox, and when i'm inspecting with firebug it clearly specify that Jsonview inserts his own css :/ capture

bhollis commented 10 years ago

Could you perhaps post a screenshot? What should I be looking for? What is different from how it should be?

On Aug 23, 2014, at 6:58 PM, Georges notifications@github.com wrote:

I'm using firefox, and when i'm looking with firebug it clearly specify that Jsonview insert his own css :/

— Reply to this email directly or view it on GitHub https://github.com/bhollis/jsonview/issues/80#issuecomment-53174231.

Geolim4 commented 10 years ago

The black huge border shouldn't be there :/

jdevney commented 9 years ago

Hi Ben, Hope this isn't too late to contribute to this thread, but I find the same also. The following URL loads plain text in the browser: http://feed.entertainment.tv.theplatform.com/f/LgiPlP/upc-pl-prod-oesp-cat-ch?startIndex=0&endIndex=19999&count=true&cid=a8e1a40f-7c19-42d2-8db9-5010dfcf7a4f However if you curl the URL then you can see the header info: curl "http://feed.entertainment.tv.theplatform.com/f/LgiPlP/upc-pl-prod-oesp-cat-ch?startIndex=0&endIndex=19999&count=true&cid=a8e1a40f-7c19-42d2-8db9-5010dfcf7a4f" -I HTTP/1.1 200 OK Date: Tue, 19 May 2015 14:36:51 GMT X-Cache: MISS from feed.entertainment.tv.theplatform.com Expires: Tue, 19 May 2015 15:36:51 GMT Last-Modified: Tue, 19 May 2015 14:36:52 GMT Content-Type: application/json; charset=UTF-8 Access-Control-Allow-Origin: * Connection: close Server: Jetty(8.1.16.2) I have the "application/json" radio ticked for HTTP Accept header . Thanks! JD.

bhollis commented 9 years ago

@jdevney I'm afraid yours is a totally different issue to this. While curl may provide the right response, visiting that URL in Firefox gets a response content type of text/plain;charset=UTF-8. It looks like that service's attempt at content negotiation is not working.

jdevney commented 9 years ago

How curious! Firebug shows the following in the request headers section:

GET /f/LgiPlP/upc-pl-prod-oesp-cat-ch?startIndex=0&endIndex=19999&count=true&cid=a8e1a40f-7c19-42d2-8db9-5010dfcf7a4f HTTP/1.1 Host: feed.entertainment.tv.theplatform.com User-Agent: Mozilla/5.0 (X11; Linux x8664; rv:29.0) Gecko/20100101 Firefox/29.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8 Accept-Language: en-GB,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Connection: keep-alive If-Modified-Since: Thu, 21 May 2015 10:57:14 GMT Cache-Control: max-age=0

Clearly there's no JSON detail there at all.

Clicking through various options in the firebug details it is possible to get a json description for the data (Net > All > [Expand GET request] > JSON) so I can at least get some useful info for when i'm debugging this feed.

Thanks for your response. Happy coding!

bhollis commented 9 years ago

I can no longer reproduce this because the original URL is gone. Please reopen if you can re-host it.