javascript - 不同机器中相同的 AJAX 请求以不同的格式返回
问题描述
我有以下问题:如果我在我的开发环境中发出 AJAX 请求,我会得到以下(缩写)原始结果:
{
"id": 37988,
"technique_id": 20,
"task_area_id": 1,
"task_area_name": "Gestao",
"order": 3,
"text": 437,
"unscheduled": 0,
"start_date": "17-10-2018",
"hours": 4,
"adjusted_hours": 4,
"done_hours": 0,
"duration": 1,
"progress": null,
"status": null,
"worker": 53,
"priority": 1,
"parent": 236,
"readonly": 0,
"cancreate": 0
},
另一方面,当我在我的产品环境中调用它时:
{
"id": "37988",
"technique_id": "20",
"task_area_id": "1",
"task_area_name": "Gest\u00e3o",
"order": "3",
"text": "437",
"unscheduled": "0",
"start_date": "17-10-2018",
"hours": "4",
"adjusted_hours": "4",
"done_hours": "0",
"duration": "1",
"progress": null,
"status": null,
"worker": "53",
"priority": "1",
"parent": "236",
"readonly": "0",
"cancreate": "0"
},
请注意,在我的 prod 上,int 值被转换为字符串。代码是一样的,数据库是一样的。
数据库调用也是一样的,在这两种情况下,数字都返回为 int,那么为什么在一种情况下保留 int 格式而在另一种情况下将其转换为字符串?
任何人都知道为什么会这样?
提前致谢!
解决方案
使用以下
JSON.stringify(obj);
推荐阅读
- android - 如何将前台应用程序设置为不显示在最近列表中?
- spring - 将 Spring Boot 与 ActiveMQ Artemis 和 MQTT 一起使用时出错
- java - Android:使用来自 MediaRecorder 的 getMaxAmplitude(),同时使用来自 TarsosDSP 的 PercussionOnsetDetector
- r - 在 R 中,如何使用 ggplot 或其他东西用数据集(csv 文件)填充地图的颜色?
- python - xx[:,9] 和 xx[:][9] 的区别?
- snowflake-cloud-data-platform - 是否可以使用雪花分割超过 8 GB 的较大文件?
- python - 检查浮点值是否在numpy数组中
- python - 为什么 SciPy 的 ODE 求解器不能产生正确的解?
- spring-boot - spring boot rest api调用
- sip - SIP INVITE 消息中的 INVITE 字段和 To 字段有什么区别?