开发者

Does JSON have a +json suffix convention?

XML has a convention whereby non-standard mime types based on XML take on a '+xml' suffix (u开发者_开发技巧seful for syntax-highlighting, etc). This is outlined by RFC3023.

I've taken a look at RFC4626 but I can't find any mention of something similar for JSON. Does JSON have a similar convention? Is it documented anywhere?


Yes the +json suffix is described in the following RFC: https://www.rfc-editor.org/rfc/rfc6839


XML has a variety of media types out there. Some common ones are:

  • XHTML (extensible hypertext markup language) application/xhtml+xml
  • SVG (scalable vector graphics) image/svg+xml
  • RSS (really simple syndication) application/rss+xml

Each MIME type identifies a different language.

RFC 3023 standardizes the convention of using the suffix +xml as rightly pointed out by you.

Paraphrased from the wikipedia article - XML and MIME.

Update: Removed incorrect assumption that JSON is not used as an alternative representation for XML.

There are alternate MIME types with suffix +json being widely used. And as rightly pointed out these will continue grow considering JSON.

The +json suffix convention is non-standard, but being used by others.


There is an ongoing specification process for "application/" subtype "+json" in A JSON Media Type for Describing the Structure and Meaning of JSON Documents in draft status writing this. Further resources are available at http://json-schema.org/.


The GitHub API uses custom JSON mime types.

http://developer.github.com/v3/media/

You could adopt their conventions.

I don't think it's been documented in the same way as custom XML mime types have. I think it's useful, though, and that it ought to be documented. In the meantime you can use them, and understand that some tools won't recognize the mime type as JSON.


I have seen such convention being used, yes. This is not something JSON (the specification) has to specify, although maybe later revisions could suggest guidelines. Most likely it would be defined as a separate RFC.

You might want to ask this question on a mailing list such as restful-json, where there are more experts who could give more complete answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜