JSON 内容类型有许多“标准 ” :
application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
我用哪一种,在哪里?我假设安全和浏览器支持问题是一个因素。
相关:如果JSON被REST API送回,什么MIME类型?
JSON 内容类型有许多“标准 ” :
application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
我用哪一种,在哪里?我假设安全和浏览器支持问题是一个因素。
相关:如果JSON被REST API送回,什么MIME类型?
当前回答
为了补充先前的答复,根据W3C,JSON链接数据(JSON-LD)的MIME类型是:
应用程序/ld+json 类型名称: 应用程序 子类型名称: ld+json
此外,来自同一来源的:
文件扩展名:.jsonld
其他回答
并非所有内容类型应用程序/json都有效。
如果您正在使用 Ext JS 表格提交到上传文件, 请注意, 服务器响应由浏览器解析, 以创建 < iframe > 的文档 。
如果服务器正在使用 JSON 发送返回对象, 则内容- 类型页眉必须设置为文本/ html , 以便告诉浏览器将文本插入文档正文, 未改变 。
见Ext JS 3.4.0 API文件。
在 JSP 中,您可以在页面指令中使用此指令 :
<%@ page language="java" contentType="application/json; charset=UTF-8"
pageEncoding="UTF-8"%>
JSON的正确MIME媒体类型是申请/json, JSP将用来向客户发送回复。
在春天,您有一个定义型号: MedicType.Application_Json_value, 相当于申请/json。
内容- 类型页眉在张贴时应该设置为“ 应用程序/ json ” 。 监听请求的服务器应该包括“ 接受= 应用程序/ json ” 。 在 Spring MVC 中, 您可以这样做 :
@RequestMapping(value="location", method = RequestMethod.POST, headers = "Accept=application/json")
回复中的添加页眉 :
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
“申请/json”是JSON正确的内容类型。
def ajaxFindSystems = {
def result = Systems.list()
render(contentType:'application/json') {
results {
result.each{sys->
system(id:sys.id, name:sys.name)
}
}
resultset (rows:result.size())
}
}