“application/json“,“text/plain“ 分别表示什么
这两个字符串:“application/json” 和 “text/plain” 是 MIME 类型(媒体类型),用于告诉接收方消息内容的格式,它们出现在 ContentType 字段中。
它告诉系统或程序:“这段数据是什么格式?”
格式通常是:主类型/子类型,例如:
text/plain
application/json
image/png
application/pdf
1. “text/plain” — 纯文本
表示消息体是纯文本内容,没有格式,也不是结构化数据。
2. “application/json” — JSON 格式
表示消息体是JSON 格式的结构化数据
MIME 类型 | 说明 | 示例内容 | 场景 |
---|---|---|---|
"text/plain" | 普通文本,无结构 | "hello world" | 简单消息、日志 |
"application/json" | 结构化数据 | {"id":1,"msg":"ok"} | 数据交互、API消息 |
plain是指?application是指?
MIME 类型格式是:主类型/子类型
所以你问的 “text/plain” 和 “application/json” 中的:plain 是子类型, text 和 application 是主类型(type)
🔹 举例:
text/plain: 普通文本,如 “hello world”、没有格式
text/html: HTML 文本,如 <h1>Hello</h1>
text/css: CSS 文件
text/csv: 表格数据,如 CSV 文件
application/json: 结构化数据,如 {“id”: 1}
application/xml: XML 格式的数据
application/pdf: PDF 文档
application/octet-stream: 任意二进制流(比如文件上传)
application/zip: ZIP 压缩包
主类型 | 表示什么 | 例子 |
---|---|---|
text | 人类可读的文本(可直接打开) | text/plain 、text/html |
application | 应用程序专用数据(结构化或二进制) | application/json 、application/pdf |
text:面向人类阅读(比如 HTML、纯文本)
application:面向程序处理(比如 JSON、PDF、ZIP)