错误:无效的字符' '从字面上看(期望' e') - 发布API JSON

发布于 2025-01-30 02:12:01 字数 1574 浏览 3 评论 0原文

我正在尝试使用帖子方法来插入一些患有JSON的人的数据。我正在使用JS构造的代码,但是当我启动转换时,它会给我发送:

“错误:无效的字符''字面true(期望'e')。

有人知道如何解决吗?

const obj = {
  "num_matricula": num_matricula,
  "limit_date": "2022-05-20",
  "admission_date": admission_date,
  "cost_center": cost_center,
  "pos_number": pos_number,
  "role": role,
  "department": department,
  "pagamento": {
    "vinculo": vinculo,
    "valor": valor,
    "recorrencia": recorrencia,
    "contaBancaria": {
      "banco": "001",
      "carta": "c9160763-db6c-4e8c-a1ad-ad8709c99be2"
    }
  },
  "deficiencia": deficiencia,
  "jornada": jornada,
  "profile": {
    "name": name,
    "email": email,
    "mobile": mobile
  },
  "exame": {
    "clinica": "6dc84ce4-7d9f-48ec-b9b1-a8a895a21fd4",
    "data": "2022-05-15",
    "hora": "14:00",
    "obs": "Comparecer de manhã",
    "guia": "e37dab24-c7a4-4b92-b9d1-32ed538b8300",
  },
  "docs": ["c9e26093-5e0c-4bd2-bea3-ac5182a6179f"],
  "send_sms": true,
  "send_email": true
};
const myJSON = JSON.stringify(obj);

一些列已经在上一步中提供了数据(您可以在下图中看到),这就是为什么我只是在JS代码中重复了列名。只是为了让您知道,布尔的类型数据是列:send_email,send_sms和deficiencia。

​/I.SSTATIC.NET/N9T8Q.PNG“ ALT =” Enter Image Description在此处”>

I am trying to use the POST method to insert some data from a person with JSON. I am using the code from JS to construct, but when i start the transformation, it sends me:

"ERROR: invalid character ' ' in literal true (expecting 'e')".

Does anyone know how to solve it?

const obj = {
  "num_matricula": num_matricula,
  "limit_date": "2022-05-20",
  "admission_date": admission_date,
  "cost_center": cost_center,
  "pos_number": pos_number,
  "role": role,
  "department": department,
  "pagamento": {
    "vinculo": vinculo,
    "valor": valor,
    "recorrencia": recorrencia,
    "contaBancaria": {
      "banco": "001",
      "carta": "c9160763-db6c-4e8c-a1ad-ad8709c99be2"
    }
  },
  "deficiencia": deficiencia,
  "jornada": jornada,
  "profile": {
    "name": name,
    "email": email,
    "mobile": mobile
  },
  "exame": {
    "clinica": "6dc84ce4-7d9f-48ec-b9b1-a8a895a21fd4",
    "data": "2022-05-15",
    "hora": "14:00",
    "obs": "Comparecer de manhã",
    "guia": "e37dab24-c7a4-4b92-b9d1-32ed538b8300",
  },
  "docs": ["c9e26093-5e0c-4bd2-bea3-ac5182a6179f"],
  "send_sms": true,
  "send_email": true
};
const myJSON = JSON.stringify(obj);

Some columns are already provided with data from previous step (you can see in the images below), that is why i just repeated the column name in the JS code. Just to let you know, the boolean types of data are the columns: send_email, send_sms and deficiencia.

enter image description here

enter image description here

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傾城如夢未必闌珊 2025-02-06 02:12:02

问题是JSON是一个字符串。因此,在第一行中,您会看到这不是有效的JSON:“ num_matricula”:num_matricula,

只有数字可以没有双引号:“ num_matricula”:1234,

The problem is that JSON is a string. So in your first line you see this is not valid json: "num_matricula": num_matricula,

only numbers can be without double quotes: "num_matricula": 1234,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文