【发布时间】:2022-01-30 08:36:56
【问题描述】:
由于某种原因,当我通过 Postman 将 JSON 格式的数据作为原始文本发送时,我没有任何问题。当我通过 Postman 发送与原始 JSON 完全相同的数据时(区别应该只是 content-type 标头是 application/json 而不是 application/text),我的双引号被剥离,字符串切换到单引号.
原始有效负载示例(邮递员发送此):
{ "id": "blahblahbloo", "time": "hammer" }
意外转换(NextJS 收到这个):
{ id: 'blahblahbloo', time: 'hammer' }
需要说明的是,当我通过 Postman 作为原始文本 发送时,我得到了完全相同的结果(这是我所期望的):
// Postman sends this and NextJs receives this when set to raw text
{ "id": "blahblahbloo", "time": "hammer" }
我没有明确地做任何事情来读取content-type 并转换数据。我遇到此问题的端点是 NextJS 动态路由:https://nextjs.org/docs/api-routes/dynamic-api-routes
【问题讨论】:
标签: json next.js postman mime-types double-quotes