application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
我用哪一种,在哪里?我假设安全和浏览器支持问题是一个因素。
application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
我用哪一种,在哪里?我假设安全和浏览器支持问题是一个因素。
当前回答
正确的 MIME 类型是application/json
但是
我经历过许多浏览器类型或框架用户需要的场景:
text/html
application/javascript
其他回答
缩略
application/json
PHP 中保存数组或对象数据的工作非常出色 。
我用这个代码把数据输入JSONGoogle Cloud 储存(GCS)设定了可公开观看:
$context = stream_context_create([
'gs' => [
'acl'=>'public-read',
'Content-Type' => 'application/json',
]
]);
file_put_contents(
"gs://BUCKETNAME/FILENAME.json",
json_encode((object) $array),
false,
$context
);
要返回数据是直线前进的:
$data = json_decode(file_get_contents("gs://BUCKETNAME/FILENAME.json"));
“application/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())
}
}
由于你可能必须更经常地使用这些内容,即使有,也总是尽量记住这三种内容类型。许多内容类型:
JSON 的正确内容类型是application/json
除非你们在使用贾索普,也称为 Json with Padding, 实际上是 JavaScript, 所以正确的内容类型将是application/javascript
.