【发布时间】:2021-06-23 21:17:16
【问题描述】:
在邮递员中,我已经完成了表单数据 KEY -products VALUE-
[
{ name: "Pizza", price: "10", quantity: "7" },
{ name: "Cerveja", price: "12", quantity: "5" },
{ name: "Hamburguer", price: "10", quantity: "2" },
{ name: "Fraldas", price: "6", quantity: "2" },
];
在代码中,我想接收同样的对象数组,但我可以将它作为字符串接收。我的代码是
var products =req.body.products;
console.log(typeof(products))//string shows
var Products=JSON.parse(JSON.stringify(products))
console.log(typeof(Products))// it also string shows
如果我打印数组 0 索引值,它会打印“[”数组括号 请帮帮我,我是新来的。 谢谢
【问题讨论】:
标签: javascript arrays postman