Skip to content

Instantly share code, notes, and snippets.

@nguyenit67
Last active November 9, 2022 11:45
Show Gist options
  • Select an option

  • Save nguyenit67/6e0cde922543de96300b98cb0b724b5a to your computer and use it in GitHub Desktop.

Select an option

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`
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