<small id='3lsqM'></small><noframes id='3lsqM'>

<tfoot id='3lsqM'></tfoot>
<i id='3lsqM'><tr id='3lsqM'><dt id='3lsqM'><q id='3lsqM'><span id='3lsqM'><b id='3lsqM'><form id='3lsqM'><ins id='3lsqM'></ins><ul id='3lsqM'></ul><sub id='3lsqM'></sub></form><legend id='3lsqM'></legend><bdo id='3lsqM'><pre id='3lsqM'><center id='3lsqM'></center></pre></bdo></b><th id='3lsqM'></th></span></q></dt></tr></i><div id='3lsqM'><tfoot id='3lsqM'></tfoot><dl id='3lsqM'><fieldset id='3lsqM'></fieldset></dl></div>

  • <legend id='3lsqM'><style id='3lsqM'><dir id='3lsqM'><q id='3lsqM'></q></dir></style></legend>
      • <bdo id='3lsqM'></bdo><ul id='3lsqM'></ul>

        在 Postman 中将多级响应对象可视化为表

        时间:2023-10-20

          1. <small id='UTIpy'></small><noframes id='UTIpy'>

            • <bdo id='UTIpy'></bdo><ul id='UTIpy'></ul>
              <i id='UTIpy'><tr id='UTIpy'><dt id='UTIpy'><q id='UTIpy'><span id='UTIpy'><b id='UTIpy'><form id='UTIpy'><ins id='UTIpy'></ins><ul id='UTIpy'></ul><sub id='UTIpy'></sub></form><legend id='UTIpy'></legend><bdo id='UTIpy'><pre id='UTIpy'><center id='UTIpy'></center></pre></bdo></b><th id='UTIpy'></th></span></q></dt></tr></i><div id='UTIpy'><tfoot id='UTIpy'></tfoot><dl id='UTIpy'><fieldset id='UTIpy'></fieldset></dl></div>
                <tbody id='UTIpy'></tbody>
              <tfoot id='UTIpy'></tfoot>
                <legend id='UTIpy'><style id='UTIpy'><dir id='UTIpy'><q id='UTIpy'></q></dir></style></legend>
                  本文介绍了在 Postman 中将多级响应对象可视化为表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想将 Postman 测试中的以下数据可视化为一个表格,其中列中有 productpricequantity行中的项目.可能有多个 shippingGroups.

                  I would like to visualize the data below in Postman Tests as a Table with product, price and quantity in columns and Items in rows. There might be multiple shippingGroups.

                  {
                     ...
                     "companyGroups": [
                          {
                              ...
                              "shippingGroups": [
                                  {
                                      "id": 1,
                                      "items": [
                                          {
                                              "product": "Product A",
                                              "price": 2,
                                              "quantity": 1,
                                          },
                                            {
                                              "product": "Product B",
                                              "price": 4,
                                              "quantity": 4,
                                          }
                  
                                      ],
                                      ...
                              ]
                          }
                      ],
                  

                  我在使用 {{#each response???}} 引用多个级别对象中的项目时遇到问题.预期的格式应该是这样的:

                  I have trouble using the {{#each response???}} referring to items within multiple level objects. Expected format should be something like :

                     <table>
                          <tr>
                              <th>Product</th>
                              <th>Price</th>
                              <th>Quantity</th>
                          </tr>
                  
                          {{#each response???}}
                              <tr>
                                  <td>{{???product}}</td>
                                  <td>{{???price}}</td>
                                  <td>{{???quantity}}
                              </tr>
                          {{/each}}
                      </table>
                  

                  有关邮递员表可视化响应的更多信息此处

                  More info on Postman Table Visualizing Response here

                  推荐答案

                  鉴于您的响应示例,您可以使用如下内容:

                  Given your response example, you could use something like this:

                  const template = `
                     <table>
                          <tr>
                              <th>Product</th>
                              <th>Price</th>
                              <th>Quantity</th>
                          </tr>
                  
                          {{#each responseData}}
                          {{#each items}}
                              <tr>
                                  <td>{{product}}</td>
                                  <td>{{price}}</td>
                                  <td>{{quantity}}
                              </tr>
                          {{/each}}
                          {{/each}}
                      </table>
                  `;
                  
                  let responseData = []
                  
                  _.each(pm.response.json().companyGroups, (item) => {
                      _.each(item.shippingGroups, (nestedItem) => {
                          responseData.push(nestedItem)
                      })
                  })
                  
                  pm.visualizer.set(template, { responseData })
                  

                  这只是一个粗略的示例,需要重构,但它表明您可以在表格中显示响应数据.

                  This is just a rough example and would need to be refactored but it shows that you can show the response data in the table.

                  这篇关于在 Postman 中将多级响应对象可视化为表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:邮递员从 JSON 中获取值,其中等于使用 javascript 的数组中的值 下一篇:如何在 CI 环境中运行 postman 的 newman?

                  相关文章

                    <bdo id='sBvRu'></bdo><ul id='sBvRu'></ul>

                • <i id='sBvRu'><tr id='sBvRu'><dt id='sBvRu'><q id='sBvRu'><span id='sBvRu'><b id='sBvRu'><form id='sBvRu'><ins id='sBvRu'></ins><ul id='sBvRu'></ul><sub id='sBvRu'></sub></form><legend id='sBvRu'></legend><bdo id='sBvRu'><pre id='sBvRu'><center id='sBvRu'></center></pre></bdo></b><th id='sBvRu'></th></span></q></dt></tr></i><div id='sBvRu'><tfoot id='sBvRu'></tfoot><dl id='sBvRu'><fieldset id='sBvRu'></fieldset></dl></div>

                  <small id='sBvRu'></small><noframes id='sBvRu'>

                  1. <legend id='sBvRu'><style id='sBvRu'><dir id='sBvRu'><q id='sBvRu'></q></dir></style></legend>
                    <tfoot id='sBvRu'></tfoot>