My favorites | Sign in
Logo
          
New issue | Search
for
| Advanced search | Search tips
Issue 15: Look for JSON in other content types
14 people starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----
Type-Enhancement
Priority-High


Sign in to add a comment
 
Reported by djbeano2000, Mar 16, 2009
Would be nice to be able support multiple content types, maybe a user list
where you can add the types you want the parser to handle.

Comment 1 by excieve, Mar 30, 2009
Some other content types than "application/json" are quite popular (though not
correct). I can often see "application/javascript" and "application/x-javascript" for
example. So an option that would enable JSONView for given content types would be
cool. Or maybe a context menu option like "View as JSON".
Comment 2 by ben.hollis, Apr 21, 2009
Can you give some examples of products which produce JSON with incorrect content
types (that can't be easily configured to serve it correctly)?
Comment 3 by cdleary, Apr 24, 2009
I've also encountered a third-party product that responds as
'text/javascript;charset=utf-8'.

It would be nice if there were a way to try and force a page's contents to render as
JSON, regardless of the mimetype.
Comment 4 by excieve, Apr 24, 2009
Ben, from popular ones, Google uses "text/javascript" in their APIs as well as
Facebook. And they surely can't be easily configured to use "text/json". Lots of
others also use incorrect content types.
Comment 5 by ben.hollis, Apr 27, 2009
excieve, can you point me to specific examples? I looked at
http://code.google.com/apis/gdata/json.html, which pointed me at
http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json
which is served as application/json. Facebook's APIs appear to actually serve
JavaScript, not JSON (the "for (;;);" guard they put on it actually makes it not be
real JSON, though I could see adapting JSONView to specifically handle that).
Comment 6 by ben.hollis, Apr 27, 2009
(No comment was entered for this change.)
Summary: Look for JSON in other content types
Comment 7 by ben.hollis, Apr 27, 2009
 Issue 12  has been merged into this issue.
Comment 8 by ben.hollis, May 28, 2009
 Issue 25  has been merged into this issue.
Comment 9 by rostislav.hristov, Jun 16, 2009
The format I'm working with is specified at http://www.w3.org/TR/rdf-sparql-json-res/ and relies on the 
"application/sparql-results+json" content type. 

All we need is a simple UI that allows the configuration of supported content types. 
Comment 10 by ben.hollis, Jun 30, 2009
 Issue 28  has been merged into this issue.
Comment 11 by ward.dav...@gmail.com, Jun 30, 2009
Admittedly I'm close to clueless about Firefox's API, but anything I can research to
try and help fix this or do you have an idea of a fix?
Comment 12 by ben.hollis, Jul 01, 2009
I have ideas of how to properly fix this, but I mostly need time.
Comment 13 by ben.hollis, Aug 05, 2009
(No comment was entered for this change.)
Status: Accepted
Labels: -Priority-Low Priority-High
Comment 14 by gabriel....@gmail.com, Oct 08, 2009
just tried to enable nsIURIContentListener, but it's simply ignoring the interface 
mappings. Will have to read manuals. it's a pain to work out all the XPCOM versions.

Another option, to not depend on server mimetypes, is to use nsIContentSniffer to 
detect JSON patterns.
Comment 15 by jauderho, Oct 15, 2009
FYI Per the spec, the correct mime type is actually application/jsonrequest. 

http://www.json.org/JSONRequest.html
Comment 16 by ben.hollis, Oct 15, 2009
jauderho, the correct mime type is "application/json". You're referring to the
JSONRequest cross-domain JSON proposal, which to my knowledge has not been
implemented in any browser.
Comment 17 by joanllosas, Dec 05, 2009
From the book "CouchDB. The Definitive Guide":

< Content-Type: text/plain;charset=utf-8

This header tells you which mime type the HTTP response body is and its encoding. We
already know CouchDB returns JSON strings. The appropriate Content-Type header is
application/json. Why do we see text/plain? This is where pragmatism wins over
purity. Sending an application/json Content-Type header will make a browser offer you
the returned JSON for download instead of just displaying it. Since it is extremely
useful to be able to test CouchDB from a browser, CouchDB sends a text/plain content
type, so all browser will display the JSON as text.
Comment 18 by ben.hollis, Dec 05, 2009
Hi joanllosas,

JSONView works great with CouchDB - see
http://benhollis.net/blog/2009/10/12/jsonview-0-4-with-content-negotiation/ for
details. You have to enable sending "application/json" in your Accept header, and
then it'll display correctly.
Sign in to add a comment

Hosted by Google Code