【发布时间】:2018-04-24 02:43:05
【问题描述】:
我想在节点 js 中解析以下类型的数据,以便对它们执行操作。 数据:-
{"orderSummary":[ {
"name":"Wine",
"ProductPrice":"500",
"ProductQuantity":"2",
"ProductCost":"1000",
"SellerId":"2"
},{
"name":"Whisky",
"ProductPrice":"500",
"ProductQuantity":"2",
"ProductCost":"1000",
"SellerId":"2"
}]
}
这是我用来解析数据的代码 sn-p:-
router.post('/createorder',function(req,res){
console.log(req.body);
var data=req.body;
var obj=JSON.parse(data);
res.send(obj);
});
谁能告诉我除了循环(因为我将实现它)以解析数据并对其执行操作之外我还能做什么?
【问题讨论】:
-
我已经完成了这个,但我仍然无法找到确切的答案,因为我的数据来自应用程序作为输入数据中显示的键值参数
-
@atulkumar 请更清楚您要完成什么。
-
这取决于你想要做什么解析操作......具体。
-
我想访问元素并将其存储在数据库中
标签: javascript json node.js