【发布时间】:2018-10-28 04:05:48
【问题描述】:
我正在尝试在 Postman 的 Tests 下编写一个 console.log 来做两件事
1- 计算响应正文中收到的类型/唯一“ShipmentStatus”的数量(处理中、已发货和已拒绝)
2 - 例如,我们收到的每个 ShipmentStatus 有多少(4 个订单在处理中,5 个订单在完成)
如何完成 1 和 2 以显示在我的 console.log 中?
"Orders": [
{
"id": 544789,
"Company": {
"ClientName": "Therese",
},
"Shipping": {
"Address": "Street,",
},
"userId": "1413260",
"ShipmentStatus": "In-Process"
},
{
"id": 544787,
"Company": {
"ClientName": "Therese",
},
"Shipping": {
"Address": "Street,",
},
"userId": "1413260",
"ShipmentStatus": "Shipped"
},
{
"id": 544786,
"Company": {
"ClientName": "Therese",
},
"Shipping": {
"Address": "Street,",
},
"userId": "1413260",
"ShipmentStatus": "Rejected"
},
我可以通过执行以下操作获得收到的总记录
console.log("Total Orders : " + response.Orders.length);
【问题讨论】:
-
你真的有问题吗?
-
我刚刚添加了问题..lol
-
到目前为止你尝试了什么?它不必是语法正确的,即使只是一个伪代码算法
-
提供的任何答案有用吗?
标签: javascript postman