有许多“标准”为“标准”Json Json (Json Json) (Json Json Json) (Json Json) Json Json (Json Json) Json (Json) Json (Json) Json (Json) Json (Json) Json (Json) Json (Json) Json(Json) Json (Json) Json (Json) Json(Json) Json (Json) Json内容类型 :

application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json

我用哪一种,在哪里?我假设安全和浏览器支持问题是一个因素。

相关:如果JSON被AST API送回来 是什么MIME类型?


当前回答

最常见的MIME 类型这是应用程序/json。 这是所有 JSON 内容类型的列表 :

过时类型 :

  • Content-Type: text/javascript - JavaScript 但是,但用于 HTML 属性的旧的因特网探索者版本。
  • Content-Type: text/x-javascript- JavaScript媒体类型,但是,但过时

其他回答

JSON 文本:

application/json

JSON 文本的 MIME 媒体类型是application/json。默认编码为 UTF-8。(资料来源:RFC 4627)

用于贾索普(可调回 JavaScript) 调回 :

application/javascript

以下是相关评论中提到的一些博客文章:

JSON 的正确内容类型是application/json除非你们在使用贾索普,也称为 Json with Padding, 实际上是 JavaScript, 所以正确的内容类型将是application/javascript.

正确的答案是:

Content-Type: application/json

PHP 开发商使用此功能 :

<?php
    header("Content-type: application/json");

    // Do something here...
?>

正确的 MIME 类型是application/json

但是

我经历过许多浏览器类型或框架用户需要的场景:

text/html

application/javascript