Visualizer does not use response

Hello,
i try to use the visualize-option but my response is not been used and I do not know why…

My response looks like this as pretty:
{

"resultSet": {

    "results": [

        [

            "200",

            55123

        ]

    ]

},

"metaData": {

    "cols": [

        [

            "Bezeichnung",

            12

        ],

        [

            "ANZAHL",

            4

        ]

    ]

},

"sql": "SELECT BEZ as Bezeichnung, Count(BEZ) as ANZAHL\n\nFROM DB.DBnew\n\nGROUP BY BEZ",

"uuid": "1f313663-9543-5ed0-af85-cad5e9a23a8d",

"done": true,

"started": 1545635049552

}

and i inserted the following code in the Test-Tab:

ar template = <table bgcolor="#CCCCCC"> <tr> <th>BR</th> <th>Anzahl</th> </tr> {{#each metaData}} <tr> <td>{{Bezeichnung}}</td> <td>{{ANZAHL}}</td> </tr> {{/each}} </table>;
// Set visualizer
pm.visualizer.set(template, {
// Pass the response body parsed as JSON as data
response: pm.response.json()
});

All that I get as visualization is the table-header, but no input…
and although there should be only one table-row; 6 rows (but empty) are displayed…

Hi @kanidani

I was playing around with your example. This template code

let template = `
<table bgcolor="#CCCCCC"> 
  <tr> 
    <th>BR</th>
    <th>Anzahl</th> 
  </tr> 
    {{#each response.metaData.cols}} 
      <tr> 
        <td>{{Bezeichnung}}</td> 
        <td>{{ANZAHL}}</td> 
      </tr> 
    {{/each}} 
</table>`;

would work if the cols array held properties like this;

"metaData": {
    "cols": [
        {
            "Bezeichnung": 12
        },
        {
            "ANZAHL": 4
        }
    ]
},

Example;

Unfortunately, your response appears to have nested arrays and I’m not sure about the syntax for this.

I believe (I could be wrong) … but the {{Bezeichnung}} and {{ANZAHL}} won’t work because they are not referencing a property, but instead a value within an array.

Hi !
Thank you very much for your response!
So my json seems not to have a typical structure… :face_with_diagonal_mouth:

Now I found out that it works if I just catch any element of the array using {{0}} for “Bezeichnung” and {{1}} for “Anzahl”

{{#each response.resultSet.results}}
            <tr>
                <td>{{0}}</td>
                <td>{{1}}</td>
            </tr>
 {{/each}}

So thank you very much for helping to find a solution!

That’s interesting, thanks for sharing the update!!