我一直在忙着JSON一段时间,只是把它作为文本推出它并没有伤害任何人(我知道),但我想开始正确地做事.
我见过这样的JSON内容类型很多所谓的"标准":
application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
Run Code Online (Sandbox Code Playgroud)
但哪个是正确的,还是最好的?我认为它们之间存在安全性和浏览器支持问题.
我知道有一个类似的问题,如果REST API返回JSON,那么MIME类型是什么?,但我想要一个稍微有针对性的答案.
我刚刚为我的一个类中的"application/json"内容类型声明了一个常量.
public const string JsonContentType = "application/json";
Run Code Online (Sandbox Code Playgroud)
我不确定这是一个好习惯.
.NET框架是否具有"application/json"的预定义const?