Last active
November 9, 2022 11:45
-
-
Save nguyenit67/6e0cde922543de96300b98cb0b724b5a to your computer and use it in GitHub Desktop.
Postman JSON tree view visualizer show count of items in array or keys in an object using `jquery.json-viewer`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const responseJson = pm.response.json(); | |
| const resJsonString = JSON.stringify(responseJson); | |
| const template = ` | |
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/json-viewer/jquery.json-viewer.css"> | |
| <script src="https://cdn.jsdelivr.net/npm/[email protected]/json-viewer/jquery.json-viewer.js"></script> | |
| <style> | |
| ol, ul, li { | |
| font-size: 14px; | |
| } | |
| li { | |
| margin-bottom: 0; | |
| } | |
| .json-document { | |
| margin: 0; | |
| padding: 0; | |
| } | |
| </style> | |
| <pre id="json-renderer"></pre> | |
| <script> | |
| const data = ${resJsonString}; | |
| $('#json-renderer').jsonViewer(data); | |
| </script> | |
| `; | |
| pm.visualizer.set(template); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment